MuiCssBaseline component styleOverrides in custom theme is not working
See original GitHub issueWhat you were expecting: To be able to change the body background image using MuiCssBaseline component styleOverrides.
What happened instead: body tag is not styled at all by the theme
Steps to reproduce:
You should see a fat blue dashed border at the body of the document, but there isn’t. In contrast, RaDatagrid overrides are working.
import { defaultTheme } from 'react-admin';
import indigo from '@mui/material/colors/indigo';
import pink from '@mui/material/colors/pink';
import red from '@mui/material/colors/red';
export const myTheme = {
...defaultTheme,
palette: {
primary: indigo,
secondary: pink,
error: red,
contrastThreshold: 3,
tonalOffset: 0.2,
},
components: {
...defaultTheme.components,
RaDatagrid: {
styleOverrides: {
root: {
backgroundColor: 'green',
},
},
},
MuiCssBaseline: {
styleOverrides: {
body: {
border: '20px dashed blue',
},
},
},
},
};
Other information:
- How to change global styles in MUI 5 in general: https://stackoverflow.com/a/71469625/1385429
- https://github.com/marmelab/react-admin/pull/8216
Environment
- React-admin version: 4.5
- Last version that did not exhibit the issue (if applicable): n/a
- React version: 18
- Browser: Chrome
Issue Analytics
- State:
- Created 10 months ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
[CssBaseline] Gives typescript error when styleOverrides ...
Duplicates I have searched the existing issues Latest version I have ... components: { MuiCssBaseline: { styleOverrides: (theme: Theme) ...
Read more >Mui v5 styleOverrides not working with themes - Stack Overflow
The issue is that Select doesn't define any styles of its own at ... const theme = createTheme({ components: { MuiSelect: { styleOverrides: ......
Read more >CSS Baseline - Material UI - MUI
The CssBaseline component helps to kickstart an elegant, consistent, ... const theme = createTheme({ components: { MuiCssBaseline: { styleOverrides: ...
Read more >Global Styling with Material-UI Theme Overrides and Props
Learn how to use global CSS overrides and default props in a theme to customize all instances of a Material-UI component in a...
Read more >@mui/material CssBaseline TypeScript Examples
StrictMode> <CssBaseline /> <ThemeProvider theme={appTheme}> <BrowserRouter> ... const theme = createCMSDefaultTheme({ mode }); let component; if (loading) ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks man! I was trying al sorts of combinations including
MuiScopedCssBaseline
, but didn’t tryScopedCssBaseline
…You are right! Sorry I missed that