首页 > 解决方案 > MUI dark theme isn't applied to the background

问题描述

I have my react application where I want to apply MUI darkBaseTheme. Without it, part of my app looks like this:

enter image description here

After I wrap all the html stuff in my render() with:

<MuiThemeProvider muiTheme={getMuiTheme(darkBaseTheme)}>
</MuiThemeProvider>

Having those imports:

import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; // add
import RaisedButton from 'material-ui/RaisedButton'; // add
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import darkBaseTheme from 'material-ui/styles/baseThemes/darkBaseTheme';

It looks like this:

enter image description here

So it changed RaisedButtons. I know it shouldn't change html ones. But why didn't it change the background to dark? Is there a way to do this, or do I have to do it manually without MUI?

标签: reactjsmaterial-ui

解决方案


您需要<CssBaseline />在应用程序的根目录中包含该组件,因为这涉及更改主体上的背景颜色。

文档


推荐阅读