首页 文章

如何实现React Material UI的全局主题?

提问于
浏览
0

我想更改特定的Material组件样式,例如 ListItemText ,在我的情况下,我更喜欢使用 theme 变量,而不是一次性解决方案,在app中处理每个材质组件 .

const theme = createMuiTheme({
    overrides: {
        ListItemText: {
            root: {
                color: 'red'
            }
        }
    }
});



render(
    <MuiThemeProvider theme={theme}>
        <Router history={history}>
            <Root store={store} />
        </Router>
    </MuiThemeProvider>
   ,
    document.getElementById('root')
)

我试图在官方文档(https://material-ui-next.com/customization/themes/#customizing-all-instances-of-a-component-type)之后覆盖 ListItemText 的颜色,但不起作用 .

我错过了什么?

1 回答

相关问题