This was a tricky problem that I took a while to wrap my head around and implement.
Basically, I needed to change the font and background-color of a material UI button, when I hover over it.
The standard documentation was mainly to use className to change - which did nothing to the selected property. Because the specificity is lower. Using external CSS also fails due to lower specificity.
After fiddling around, I realized that this is the only way:
Step 1:
I’ll need to define makestyles as such:
| |
basically this compiles to .root-x.selected-x {color: blue;}; or, in my case, .makeStyles-root-1.makeStyles-selected-2, whose specificity is higher than the default one which is .MuiToggleButton-root.Mui-selected.
Step 2:
It’s crucial that I include both generated DOM names, root and selected
| |
For reference: the classes prop of the MUI component ‘use classes to provide an object that maps name of classes to override (.MuiToggleButton-root.Mui-selected) to css class names to apply. class.whatever (defined above)’