-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ThemeOptions TS typings appear to be incomplete #11853
Comments
Would you like to submit a PR? |
I'll take a stab on it. |
@Slessi I think only |
|
@oliviertassinari I see. Then I think we should allow the flexiblity in typings for people to specify any props. I'll make the change accordingly in that PR. |
If this is just about theme customization, is it not covered by this? |
@pelotom Good point. I didn't read that part. |
@franklixuefei They were in |
@franklixuefei Was this handled in your PR? Doesn't work for me when I try it out with the changes. |
@Slessi No, you need to follow the docs. |
The docs are what brought me here: https://material-ui.com/customization/themes/#createmuitheme-options-theme This was listed as an example: import { createMuiTheme } from '@material-ui/core/styles';
import purple from '@material-ui/core/colors/purple';
import green from '@material-ui/core/colors/green';
const theme = createMuiTheme({
palette: {
primary: purple,
secondary: green,
},
status: {
danger: 'orange',
},
}); And in TS this results in:
|
@Slessi for theme customization in TypeScript see https://material-ui.com/guides/typescript/#customization-of-theme |
@pelotom aha, didn't realise that was how you're expected to do it in TS. Thanks |
@pelotom @Slessi - I am also stuck on this problem. I tried it as the docs say but could not get contrastThreshold and tonalOffset to work. Appreciate your help. I think I got it to work as with the same logic, as given in docs, I changed the PaletteOptions in createPalette declaration. import {
Palette,
PaletteOptions
} from "@material-ui/core/styles/createPalette";
declare module "@material-ui/core/styles/createPalette" {
interface Palette {
contrastThreshold: number;
tonalOffset: number;
}
interface PaletteOptions {
contrastThreshold?: number;
tonalOffset?: number;
}
} If my approach is incorrect please let me know. |
@nagarajay so it's working then? It looks fine to me. |
@pelotom Yes! It seems to be working. Thanks for providing direction. |
@nagarajay naive question here: what did you name the file that you put the augmented module declaration in? |
yes it does, thanks @oliviertassinari! in our project, we ended up following that pattern and putting it in:
|
You have to declare the modules to extend the default styles of material UI e.g for pallete... |
In the documentation for themes it is suggested that you can do the following:
But it appears that the
ThemeOptions
interface accepted bycreateMuiTheme
does not have the propertiesstatus
,contrastThreshold
ortonalOffset
. Not sure if its the docs or the typings which are incorrect.Expected Behavior
Typings match what the documentation says you should be able to do
Current Behavior
Typings do not match what the documentation says you should be able to do
Your Environment
The text was updated successfully, but these errors were encountered: