I recently had a project with a requirement to support theming on the website. So, I’m building a webSite and I’m using ThemeProvider to style it. I have a main layout where I provide all my css. The problem is when I navigate through pages, my navigation bar and breadcrumbs css change according a specified page like the example below. What could be the problem here?
let theme = createTheme({
palette: {
primary: {
light: '#63ccff',
main: '#C66262',
dark: '#006db3',
},
},
typography: {
h5: {
fontWeight: 500,
fontSize: 26,
letterSpacing: 0.5,
},
},
});
theme = {
...theme,
components: {
MuiButton: {
styleOverrides: {
root: {
textTransform: 'none',
},
contained: {
boxShadow: 'none',
'&:active': {
boxShadow: 'none',
},
},
},
},
MuiIconButton: {
styleOverrides: {
root: {
padding: theme.spacing(1),
},
},
},
MuiDivider: {
styleOverrides: {
root: {
backgroundColor: 'rgb(255,255,255,0.15)',
},
},
},
MuiListItemButton: {
styleOverrides: {
root: {
'&.Mui-selected': {
color: '#4fc3f7',
}
},
},
},
MuiListItemText: {
styleOverrides: {
primary: {
color: '#fff',
fontSize: 14,
fontWeight: theme.typography.fontWeightMedium,
},
},
},
MuiListItemIcon: {
styleOverrides: {
root: {
color: '#fff',
minWidth: 'auto',
marginLeft: theme.spacing(2),
'& svg': {
fontSize: 20,
},
},
},
},
},
};
const AppLayout = ({ children, style, title, onClick, bottomNav = false }) => {
return (
<ThemeProvider theme={theme} >
<Box sx={{ display: 'flex', minHeight: '100vh' }}>
<CssBaseline />
<Box
component="nav"
sx={{ width: { sm: drawerWidth }, flexShrink: { sm: 0 } }}
>
{isSmUp ? null : (
<Navigator
PaperProps={{ style: { width: drawerWidth, backgroundColor:"#081627" } }}
variant="temporary"
open={mobileOpen}
onClose={handleDrawerToggle}
/>
)}
<Navigator
PaperProps={{ style: { width: drawerWidth, backgroundColor:"#081627" } }}
sx={{ display: { sm: 'block', xs: 'none' } }}
/>
</Box>
<Box sx={{ flex: 1, display: 'flex', flexDirection: 'column' }}>
<Header onDrawerToggle={handleDrawerToggle} />
<Box component="main" sx={{ flex: 1, py: 6, px: 4, bgcolor: '#eaeff1' }}>
<Paper>
{children}
</Paper>
</Box>
<Box component="footer" sx={{ p: 2, bgcolor: '#eaeff1' }}>
<Copyright />
</Box>
</Box>
</Box>
</ThemeProvider >
);
};
export default AppLayout;

