I'd like to change the styling of a Material-UI RaisedButton on hover, but it seems like there is no specific option to do that, as what happens on hover is sort of defined by material design guidelines.
Nevertheless, is there any way to change a button's styling (mainly color and background-color) when hovering over them?
I see m-ui is using a lot of different layers for their buttons, and currently adds a white transparent background on top of the button so that it performs well with all theme colours.
(To be more precise, I'd like to invert the colours between the colour and background-color.)
sometimes 'hover' styles not applying even though you applied. U can achieve using '!important'.
Sorry for a late answer, but maybe this will help someone else. Material-ui supports media queries like this (at least with 1.0):
This example and more can be found from Mark Dalgleish's post about unified styling language.
Just try this, you can create
className
in reactjs, so you can do hover style..You'll have to use CSS and some hackery, but below is a little component that wraps it up.
https://jsfiddle.net/0gjs8bh3/3/
Example:
You could choose to do the CSS differently here, but I am just trying to encapsulate it for you here on SO to make it more easily testable. If you choose to implement this differently, the key points are:
1) You need to use CSS
:hover
on the<button>
element that RaisedButton renders2) You must initialize the
RaisedButton
's props with the colors inverted already (this is because material-ui uses the label color to determine hover overlay and ripple color). Use your CSS to 'fix' the swapped colors when not :hover'ing.3) You need match the transition that material-ui uses on the button's label, or it won't animate correctly
NOTE: If you are using material-ui's custom theming, you could modify this component to use the raisedButton theme's primary/secondary colors rather than accepting custom colors.