question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Button's custom color property

See original GitHub issue

Hi there!

I’ve added some new colors to theme.palette. And primary, secondary buttons have own classes like MuiButton-outlinedPrimary based on variant value.

When i override Button color property component with my own palette colors MuiButton-outlinedPrimary and etc. classes disappear. Therefore hover background-color styles disappear, and I don’t know how to add suitable background-color with opacity.

Perhaps the solution is to add a hover property to buttons, but how to convert HEX to RGBA like rgba(83, 109, 254, 0.08)

Differences between default Button and custom, as you can see hover color is different

image

Custom button

image image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sakulstracommented, Nov 12, 2019

If I understand this correctly it’s basically a request for dynamic colors in buttons. More or less a dupe of https://github.com/mui-org/material-ui/issues/13875

In the code you’re only overwriting the default style. Have a look at https://github.com/mui-org/material-ui/blob/master/packages/material-ui/src/Button/Button.js#L21 if you want to check how it’s done in core.

A for now simpler variant would be to wrap the button with a custom theme provider, providing the palette you want to use inside your button.

0reactions
oliviertassinaricommented, Nov 12, 2019

@sakulstra Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS Buttons - W3Schools
.button · background-color: #4CAF50; /* Green */ border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block ...
Read more >
Bootstrap button – 9 demos of custom color, size, dropdown ...
This is almost the same example as above except I used a few CSS 3 properties. While this time I used btn-danger class...
Read more >
CSS Button Style – Hover, Color, and Background
To change the background color of the button, use the CSS background-color property and give it a value of a color of your...
Read more >
ion-button - Ionic Framework
CSS Custom Properties​ ; --color-focused, Text color of the button when focused with the tab key ; --color-hover, Text color of the button...
Read more >
How to Change the Button Color in HTML - wikiHow
1. Type and tags. The body is where the visible elements of a web page are placed using HTML. 2. Type style= after...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found