I am working with react components these days and had some issue in styling one of my buttons with a hover style. Following is the code snippet I used in my component.
const darkTheme = createMuiTheme({
palette: {
type: 'dark',
secondary:amber
},
typography: {
useNextVariants: true,
}
});
const lightTheme = createMuiTheme({
palette: {
type: 'light',
secondary:amber
},
typography: {
useNextVariants: true,
}
});
Above is the custom themes I am using.
class APIWidget extends Widget {
constructor(props) {
super(props);
this.styles = {
button: {
backgroundColor: amber[500],
'&:hover': {
backgroundColor: amber[700],
},
position: 'absolute',
bottom: 20,
right: 20
},
};
}
render() {
return (
<MuiThemeProvider theme={this.props.muiTheme.name === 'dark' ? darkTheme : lightTheme}>
<Button variant="contained" color="secondary" style={this.styles.button}>
<ArrowBack style={{marginRight:15}}/>
Back
</Button>
</MuiThemeProvider>
);
}
}
global.dashboard.registerWidget('APIWidget', APIWidget);
I am using material ui and i am importing the colors from it. My button background color works while the hover color doesn't work. Can you please point out whether there is any mistake in my code or suggest any method to get the necessary hover color. Thanks in advance.