In my opinion, a more effective approach to defining custom classes within your Theme is to place them inside components/MuiCssBaseLine :
const theme = createTheme({
palette: {
primary: {
main: "#66b53f",
dark: "#66b53f",
},
secondary: {
main: "#f44336",
dark: "#ba000d",
},
},
components : {
MuiCssBaseLine : {
styleOverrides : {
body : {
"& .custom-css-class" : {
color : "white",
bgcolor : "grey",
... /* More custom styling */
}
}
}
}
}
});
By doing so, using className="custom-css-class" would be accessible globally to all child components wrapped within your ThemeProvider. Make sure to also import <CssBaseLine /> at the top of your app right after the Theme context.
import { CssBaseLine , ThemeProvider } from "@mui/material"
export default function App() {
/* Add the rest of your code here */
return (
<ThemeProvider theme={theme}>
<CssBaseLine />
<YourApp />
<div className="custom-css-class">custom-styled-content</div>
</ThemeProvider>
);
}