Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to add a custom hover color to Raised Buttons?

Working on a project that is using the Material-UI library of components and I've gotten a request for a custom button hover color that is outside of the normal convention of the MUI theme.

I found this relevant block of code in the Raised Button source, https://github.com/callemall/material-ui/blob/master/src/RaisedButton/RaisedButton.js#L98. Setting a custom labelColor does change the hover state, but that still does not satisfy my current need to have the button hover color something different than that of the label color.

overlay: {
  height: buttonHeight,
  borderRadius: borderRadius,
  backgroundColor: (state.keyboardFocused || state.hovered) && !disabled &&
    fade(labelColor, amount),
  transition: transitions.easeOut(),
  top: 0,
},

Is there a way to override the overlay background color some other way so that I can use a separate custom color?

To clarify I'm looking to do this using inline styling or through overriding a prop on the button. Appending a class and using external CSS is not an option.

like image 497
embolden Avatar asked Sep 12 '16 20:09

embolden


People also ask

How do you change the color of a button?

All style elements in your HTML button tag should be placed within quotation marks. Type background-color: in the quotation marks after "style=". This element is used to change the background color of the button. Type a color name or hexadecimal code after "background-color:".

How do I change the hover button color in squarespace?

One of the most common ways to change the hover button color in Squarespace is to use CSS. The CSS selector :hover can be used to change the color of the button when the user hovers over it with their mouse.

How do you change the color of the submit button in HTML?

Target Specific ButtonsGo to the Style tab and scroll to the bottom of the survey preview. Click the HTML/CSS Editor link. Paste in the appropriate piece of CSS code from below in the field on the Custom CSS tab. Replace the hex color value (like #000000) with the color of your choice!


1 Answers

I was able to solve it by giving a className prop to RaisedButton component and specifying :hover attribute in css with !important directive.

In your component:

...
<RaisedButton className="my-button" />
...

In your css:

.my-button :hover {
  background-color: blue !important;
}
like image 134
kosker Avatar answered Oct 01 '22 20:10

kosker