[theme] Expose the theme.palette.augmentColor function
See original GitHub issueRandom idea from a user:
material-ui removed recently the palette.palette.background.*
colors. Maybe I got it wrong, but I find these colors quite useful when creating panels and stuff for an app, having a selection of colors I can pick from.
I would be nice to have material-ui generate a decent selection of colors, based on the type of palette (light or dark). This could be done different ways:
- provide a fixed set of shade of grey
- in addition to
palette.primary
andpalette.secondary
, havepalette.background
behave the same way. Whenpalette.background.primary
is set, computedark
,light
andcontrastText
colors. For example, providinggrey[800]
would generate decent dark background shades,grey[300]
would generate light background shades. - expose the colors functions that compute
dark
,light
andcontrastText
so users are free to setup background values easily instead of harcoding colors.
In particular, this would avoid doing things like theme.palette.grey[theme.palette.type === 'light' ? 300 : 900]
in each components.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
[theme] Expose the theme.palette.augmentColor function
expose the colors functions that compute dark , light and contrastText so users are free to setup background values easily instead of harcoding ......
Read more >Palette - Material UI - MUI
The theme exposes the following palette colors (accessible under theme.palette. ): primary - used to represent primary interface elements for a user.
Read more >Using additional palettes beyond primary, secondary and error
Worked this one out. This is added on to the end of the code in the question above: theme.palette.augmentColor(theme.palette.extra, 500, ...
Read more >Top 5 @material-ui/utils Code Examples - Snyk
primary: augmentColor(primary), // The colors used to represent secondary interface elements for a user. secondary: augmentColor(secondary, 'A400', 'A200', ' ...
Read more >Using Theme Palettes - Developer Training
Theme palettes allow themes to expose sets of configuration options to ... some functional) that are consolidated behind simpler selectable named options.
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 FreeTop 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
Top GitHub Comments
@MichaelMure Thanks for the feedback. So, I believe we can move forward with the issue by exposing the
augmentColor()
function to the public API. It can be useful when dealing with a wider set of colors. I have renamed the issue accordingly.Hi, I have a PR for this: https://github.com/mui-org/material-ui/pull/10985, it’s useful for me.