更改MUI中的原色和次色 [英] Change primary and secondary colors in MUI
本文介绍了更改MUI中的原色和次色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个使用MUI的Reaction应用程序。导入按钮时,可以使用primary={true}
或secondary={true}
设置其样式。我想更改primary
和secondary
颜色。我发现我可以这样做:
const theme = createMuiTheme({
palette: {
primary: '#00bcd4',
secondary: '#ff4081'
}
});
然后我可以在这里使用它:
<MuiThemeProvider theme={theme}>
<App/>
</MuiThemeProvider>
但我收到错误:createMuiTheme is not a function...
我进入MUI包,发现没有这样的文件,当我导入createMuiTheme
时,我得到undefined
。它应该是从material-ui/styles/theme
导入的,但实际上它根本没有这个文件夹!
我使用的是material-ui@0.19.4
。我已将此包更新为v20
,但仍然没有这样的文件夹。
推荐答案
我注意到文档的两个不同之处是MuiThemeProvider的道具名称:
<MuiThemeProvider muiTheme={muiTheme}>
<AppBar title="My AppBar" />
</MuiThemeProvider>
并且函数不是createMuiTheme而是getMuiTheme:
import getMuiTheme from 'material-ui/styles/getMuiTheme';
更新:
如果您从包中打开灯光主题,他们没有使用主要主题或次要主题,或许您应该这样尝试?
这篇关于更改MUI中的原色和次色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文