[Theme] Inadeguate palette theming primitives
See original GitHub issueDisclaimer! This is a feature-request/question hybrid since I believe there are some problems on how colors are treated in v1. If maintainers think this is not the right place to discuss this I’ll aptly move it to Stack Overflow.
Problem Description
While customizing the library with a custom theme I found the way we have to specify the primary
and accent
shades a little bit controversial. Let me explain this a little bit more thoroughly.
Material Design guidelines define a set of “colors” (or “hues”) beautifully crafted by the Google Design team so that each “color” has a nicely defined set of shades (50
, 100
to 900
). Once you choose your main starting shade inside the hue, moving up and down helps in creating a visual chromatic hierarchy. Given the length of jumps required to have enough contrast inside the hue, and to give more vibrancy to the design of apps, they suggest to start at 500
and move up and down from there.
But nothing stops you from choosing a different shade as your starting point.
50 | 200 | 500 | 900 |
---|---|---|---|
![]() |
![]() |
![]() |
![]() |
In fact these screenshots have been generated by the “official” Color Tool.
The actual problem
In this library when defining the theme for the application we can specify the hue for primary or accent colors, but not the specific shade we want.
To do so we need to create a custom “color” by shifting values up or down in order to move the selected shade to the 500
(and A500
) position.
And most of the time this is required for the UI to have some chromatic sense. If you look at the documentation itself you can find an occurrence of a wrongly defined color right in the «Themes» section.
In fact this approach makes it difficult for components to extract the right colors.
Actual | Expected |
---|---|
![]() |
![]() |
«Accent» is too light | «Accent» is readable |
Proposal
It’s a little but late to change this part of the library but I believe something should be done about it; be it an utility to create new colors automatically based on a shade (shiftColor(greeen, 900)
) or a different approach.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:11
- Comments:21 (18 by maintainers)
Alright, let’s fix this issue. It’s going to be a breaking change. But I think that it’s important to simplify the situation. I have been giving a look at how Bootstrap and material-components-web palette work. We can try to copy what works best for them. Here is my proposal:
The new API
The upgrade path
Problems solved
I also stumbled upon this issue. I used mdl long time ago, lastly I tried material-component-web. Now I wanted to achieve the same result, but the need to define a whole palette just confused me a lot. The result is not what I expected, neither what the official color tool generates.
So I really hope this will change. I was just convinced to use material-ui until I came across this issue.