I'm using the Material-ui-next Select component in a project.
Most of the styles are being overriden using the classes
prop. But the selected
key can't get to work even using MuiThemeProvider
.
Here is the relevant parts of the code:
...
const theme = createMuiTheme({
overrides: {
MuiMenuItem: {
selected: {
backgroundColor: 'transparent',
}
}
}
});
...
class SelectMUI extends Component {
render() {
const {className, name} = this.props
return (
<MuiThemeProvider theme={theme}>
<Select
classes={{root: 'muisc-root', icon: 'muisc-icon', select: 'muisc-select', selectMenu: 'muisc-select-menu'}}
className={`mui-select-custom ${className}`}
endAdornment={<Caret className='mui-select-caret'/>}
MenuProps={{classes: {paper: 'muisc-menu-paper'}}}
{...this.props}
>
{this.props.children}
</Select>
</MuiThemeProvider>
)
} }
So, as you can see, while I'm importing the MenuItems as props, I'm using the MuiThemeProvider
to inject style in the items.
And here is a screenshot of the applied style in a selected item:
How to override this selector that is combining two classes from the same element?
ok, I figure it out how to override a combined selector. Here is the solution:
MuiMenuItem: {
root: {
background: 'transparent',
'&$selected': { // <-- mixing the two classes
backgroundColor: 'transparent'
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With