【发布时间】:2022-01-24 05:45:51
【问题描述】:
const DarkTheme = () => { const [dark, setDark] = useState(false) const theme = createMuiTheme({ palette: { type: dark ? 'dark' : 'light',`I want to make another color instead of dark` }, })
当我点击按钮时,我想将页面背景颜色更改为另一种颜色,而不是黑色,我该怎么办?
return ( <ThemeProvider theme={theme}> //toggle <Switch checked={dark} onChange={() => setDark(!dark)} /> <Paper> <Typography variant='h1'>This is a h1 text</Typography> <Typography variant='body2'>This is a body2 text</Typography> </Paper> </ThemeProvider> ) }
【问题讨论】: