createMuiTheme custom variables not recognized in Typescript
See original GitHub issueReference: https://material-ui.com/customization/themes/#custom-variables
I followed the reference to add custom variables as I needed more color palettes as opposed to just primary and secondary.
Typescript keeps complaining blue: { light: string; main: string; dark: string; contrastText: string; };' is not assignable to parameter of type 'ThemeOptions'
export default createMuiTheme({
palette: {
primary: {
light: '#FFB644',
main: '#FF8500',
dark: '#C55600',
contrastText: '#FFFFFF',
},
secondary: {
light: '#96F87D',
main: '#62C44D',
dark: '#2A931C',
contrastText: '#FFFFFF',
},
blue: {
light: '#72C3FF',
main: '#3393DA',
dark: '#0066A8',
contrastText: '#FFFFFF',
}
}})
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
createMuiTheme custom variables not recognized in Typescript
I followed the reference to add custom variables as I needed more color palettes as opposed to just primary and secondary. Typescript keeps ......
Read more >How to use Material UI custom theme in React with Typescript
import { createMuiTheme } from '@material-ui/core/styles'; declare module ... You can declare your custom variables in .d.ts file.
Read more >Extend Material-UI theme in TypeScript - In Plain English
Object literal may only specify known properties, and 'success' does not exist in type 'PaletteOptions'. It means that because Material-UI ...
Read more >Dark mode - Material UI - MUI
If you have a custom palette, make sure that you have the correct values based on the mode . The next section explains...
Read more >Update! Creating a Custom Material-UI Theme
We found it too difficult to create a color palette that was pleasing to ... When creating the custom theme object, I created...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
A small change I made to keep it more general is use interfaces
PaletteColor
andPaletteColorOptions
.That should do the trick.