Skip to content

Commit

Permalink
[docs] Update code snippet in docs for custom color palette (#32946)
Browse files Browse the repository at this point in the history
* test(Chip): add test case for custom color in theme palette

* fix(Chip): calculate contrastColor if custom color is provided in theme palette to avoid crash in alpha function

* revert changes

* update code snippet

* update docs

* improve indentation
  • Loading branch information
ZeeshanTamboli committed Jun 23, 2022
1 parent 2476996 commit b90770d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/data/material/customization/palette/palette.md
Expand Up @@ -87,6 +87,16 @@ const theme = createTheme({
// dark: will be calculated from palette.secondary.main,
contrastText: '#ffcc00',
},
// Provide every color token (light, main, dark, and contrastText) when using
// custom colors for props in Material UI's components.
// Then you will be able to use it like this: `<Button color="custom">`
// (For TypeScript, you need to add module augmentation for the `custom` value)
custom: {
light: '#ffa726'
main: '#f57c00',
dark: '#ef6c00',
contrastText: 'rgba(0, 0, 0, 0.87)',
}
// Used by `getContrastText()` to maximize the contrast between
// the background and the text.
contrastThreshold: 3,
Expand Down

0 comments on commit b90770d

Please sign in to comment.