这些天我正在使用反应组件,并且在使用悬停样式设计我的一个按钮时遇到了一些问题。以下是我在组件中使用的代码片段。
const darkTheme = createMuiTheme({
palette: {
type: 'dark',
secondary:amber
},
typography: {
useNextVariants: true,
}
});
const lightTheme = createMuiTheme({
palette: {
type: 'light',
secondary:amber
},
typography: {
useNextVariants: true,
}
});
Run Code Online (Sandbox Code Playgroud)
上面是我正在使用的自定义主题。
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 …Run Code Online (Sandbox Code Playgroud)