This is perhaps a simple Material UI Theme Customization question.
What I want to do is to override the default styling on <body>
(and other common tags in the future). Right now at the root of my React tree:
import theme from './mui-theme'
ReactDOM.render(
<Router>
<ThemeProvider theme={theme}>
<StylesProvider injectFirst>
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
<CssBaseline />
<App />
</StylesProvider>
</ThemeProvider>
</Router>,
document.getElementById('root'),
);
There's a theme that specifies some things but leaves out 'body1'
const theme = useTheme()
and console.log(theme)
shows that it is defined as:
typography:
body1:
fontFamily: "Roboto,"Helvetica Neue""
fontSize: "1rem"
fontWeight: 400
lineHeight: 1.5
This is the setting I want. However to use that setting I have to use the Typography
tag with variant='body1'
. Otherwise, text inside a div
has styling provided by CssBaseline
. That's the rule on the body
tag: font-size: .875rem;
which I wish to override.
Do people override styling provided by CssBaseline by using createMuiTheme? If so, I added:
body: {
fontSize: '1rem',
},
Which shows up on console.log(theme)
, but how tell the <body>
tag to actually use that style?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…