I would like to configure some colors in my theme, which are used by some categories in my application.
So I've setup a theme and use this in my component.
theme.tsx
import { createTheme, Theme } from '@mui/material/styles'
import { red } from '@mui/material/colors'
export const theme: Theme = createTheme({
palette: {
primary: {
main: blue[800]
},
secondary: {
main: '#19857b'
},
cat1: {
main: red[700]
}
}
})
circle.tsx
import CircleIcon from '@mui/icons-material/FiberManualRecord'
import {theme} from '/shared/theme'
export function Circle() {
return (
<>
<CircleIcon style={{ color: theme.palette.cat1.main }} />
<CircleIcon style={{ color: theme.palette.cat1[200] }} />
</>
)
}
What I try to achieve is to set the color of some elements in a dynamic way. So the Circle in category 1 will get the color red. All colors which are needed are imported in the theme. I don't want to import all possible colors in the component itself.
But I also want to calculate the color of another element based on this. In the example above I would like to get 200 of red.