The color
prop of Typography
is theme aware which is a nice feature of sx
prop. This means besides setting the color
as usual like this:
<Typography variant="h1" color="#00ff00">
You can reference the themed colors, either from the default palette or a custom palette defined like below:
const theme = createTheme({
palette: {
tomato: '#FF6347',
pink: {
deep: '#FF1493',
hot: '#FF69B4',
medium: '#C71585',
pale: '#DB7093',
light: '#FFB6C1',
},
},
});
After registering the custom theme
in ThemeProvider
, you can use it in Typography
by specifying the string path of the Palette
object to the color value:
<Typography color="tomato">text</Typography>
<Typography color="pink.deep">text</Typography>
<Typography color="pink.hot">text</Typography>
<Typography color="pink.medium">text</Typography>
<Typography color="pink.pale">text</Typography>
<Typography color="pink.light">text</Typography>
Here is a couple of examples of Typograhy
using the default colors from the palette:
<Typography color="primary.main">text</Typography>
<Typography color="primary.dark">text</Typography>
<Typography color="primary.light">text</Typography>
<Typography color="secondary">text</Typography>
<Typography color="text.secondary">text</Typography>
<Typography color="text.disabled">text</Typography>
