【发布时间】:2020-12-11 13:53:25
【问题描述】:
我对 React 还不是很深入...
AppBar 的样式像我不喜欢的按钮。
所以我想改变它的颜色,但也让它工作在切换明暗方案。
[编辑] 我想为 AppBar 定义自己的颜色(不更改当前颜色)并将它们分别添加到浅色/深色主题中,以便在我切换主题时自动更改为浅色/深色。 [/编辑]
使用 ThemeProvider 更改颜色已经不起作用:
const theme = createMuiTheme({
palette: {
// type: 'dark'
},
overrides: {
MuiTypography: {
h1: {
fontSize: 24,
fontWeight: "normal"
},
h2: {
fontSize: 22,
fontWeight: "normal"
},
},
MuiAppBar: {
background: 'white',
borderBottom: "1px solid lightGray",
}
},
不过,MuiTypography 可以。 (正如我在这里看到的 https://material-ui.com/customization/default-theme/ 没有 AppBar 只有排版。)
如何告诉 AppBar 使用除主要/次要颜色之外的其他颜色,同时与内置的明暗主题机制保持同步?
【问题讨论】:
标签: reactjs material-ui theming