I have a React application which is built using Material UI. I have created my own theme override (see extract below), but the colour of the font needs to be purple #391960, not rgba(0, 0, 0, 0.87). How can I override the default font colour across the entire site?
Here is an extract of my theme
import { createMuiTheme } from "@material-ui/core";
const theme = createMuiTheme({
palette: {
text: {
light: "#ffffff",
main: "#391960",
dark: "#140b1d",
},
});
export default theme;
I hoped the addition of the above in my theme.js file would cause all the font colours to change to #391960 since I haven't applied any styles to the fonts within the components. For example:
import theme from "./styles/theme";
<ThemeProvider theme={theme}>
<Typography variant="h1" component="h1">
Page Title
</Typography>
</ThemeProvider>
However, the text within the above Typography component remains dark grey. I am successfully able to change the size of this typography component with the following code, so this proves that I am pulling the theme into the component correctly:
typography: {
h1: {
fontSize: "2rem",
fontWeight: 700,
},
If I can't set the site-wide colour using the theme.js file, I was thinking that I could have a global style sheet which pulls in the correct colour from the theme somehow? For example (and I know this won't work!)
body {
color: theme.palette.main
}
Any help would be appreciated!
Thanks,
Katie