Seeking guidance on customizing a Material UI Theme
I aim to modify the default styles for elements like <body>
. Currently, 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'),
);
The provided theme does not include styling for 'body1'
const theme = useTheme()
reveals that it is defined as:
typography:
body1:
fontFamily: "Roboto,"Helvetica Neue""
fontSize: "1rem"
fontWeight: 400
lineHeight: 1.5
This 'body1' setting is desired but currently requires using the Typography
tag with variant='body1'
. Otherwise, text within a div
follows the styling set by CssBaseline
, such as font-size: .875rem;
, which I wish to change.
Is there a way to override CssBaseline styling using createMuiTheme? I have tried adding:
body: {
fontSize: '1rem',
},
While this modification shows up in console.log(theme)
, how can I ensure that the <body>
tag actually utilizes this style?