I'm using @material-ui/core to handle theming in my React app, but for some reason some of the styles are not being applied.
Here's my sandbox will the full code (relevant snippets below).
I followed the example in Material UI's docs but it doesn't seem to work.
The interesting thing is that the text does align center (which I specified in my styles), but the background color stays the default #fafafa instead of #424242 as specified in my theme. So I guess the styles are being applied but my theme is not being applied to the styles.
Another weird thing is that I logged out the value of theme.palette.background.default within the makeStyles callback and it was #424242.
Also, if I set the value of backgroundColor in the useStyles hook to a static string like #f00, it does apply (the background color changes to red).
useStyles hook:
const useStyles = makeStyles(
(theme: Theme) =>
createStyles({
root: {
backgroundColor: theme.palette.background.default,
height: "100%",
textAlign: "center",
width: "100%"
}
}),
{ name: "App" }
);
App component:
const App = () => {
const classes = useStyles();
return (
<>
<CssBaseline />
<ThemeProvider theme={darkTheme}>
<div className={classes.root}>hello</div>
</ThemeProvider>
</>
);
};
Theme
// NOTE: gray[800] = #424242
export const darkTheme = createTheme({
palette: { background: { default: grey[800] } }
});