I’m looking for a way to extend MUI v5’s MuiCssBaseline with a rule to set margin: 0
on all the heading and paragraph tags. I’ve tried this:
MuiCssBaseline: {
styleOverrides: {
'@global': {
h4 {
margin: 0
}
}
}
}
but it resulted in TS18004: No value exists in scope for the shorthand property 'h4'. Either declare one or provide an initializer
.
What’s the right way? Should it be set in MuiCssBaseline
at all?
2
Answers
Building upon the accepted answer this is what I came up with.
Below is an example of one syntax for how to handle this in the theme. You can find documentation about overriding global styles here: https://mui.com/material-ui/customization/how-to-customize/#4-global-css-override.
Another approach that is not reliant on
CssBaseline
is to use theGlobalStyles
component as show below.