[RFC] Joy color system #29496
Replies: 4 comments 5 replies
-
I understand the cons about the first option but, in general, relying on opacity kinda limits a lot of possible designs we could use in the components - at least it was what struck me while reading it.
This is put as a con but it seems to be pretty similar to what we saw Primer - GitHub's DS - does. So, it kinda makes me think, how much component-specific color definition do we want to have on the theme object? And why? What also evokes a better DX? I know there's a trade-off about the theme's length. If every component state color is defined there, the theme might get big (see Primer's). But what are other trade-offs to consider? The main con about the second option I see is not that it "might not get the exact same color as in the design" but rather that it limits the design expression of the component, which to me is a big con! Also, the |
Beta Was this translation helpful? Give feedback.
-
Slightly off topic, but is 50-900 a broadly accepted scale, or specific to Material Design 1 & 2? In MD 3 they've moved to a 0-100 scale: |
Beta Was this translation helpful? Give feedback.
-
I presume that's meant to say "tone" (or "shade" using MD 1-2 terminology). Opacity is an important tool where you do want the background color to affect that of a component, for example with states as in MD 1/2 (and so |
Beta Was this translation helpful? Give feedback.
-
Option 1 is the way to go, I'm closing this. |
Beta Was this translation helpful? Give feedback.
-
To share my findings of different alternatives for applying colors to Joy components so that I get early feedback and the understanding is shared across the team.
The final approach should have these characteristics:
1. simple but also configurable between
light
anddark
mode.This is because colors tend to be different between light & dark on the components, take Button as an example.
2. The styles inside the component should point to a variable instead of switching between colors.
This is a constraint we need to account for, otherwise, we will need to rely on JS and still have a flash issue on the SSR.
When the dark color scheme is picked, the Button color will use
[data-theme="dark"]
palette.3. Scalable across the whole components
Component states (hover, active, focus, disabled) can reuse the same variables. Or some variants like
outlined
should be able to share the colors between each component.Alternatives
Current candidate:
Option 1
Option 1: Use only the color range (50-900)
Because the styles (color) is different between light and dark mode. We cannot use the range (50-900) directly, we need to create references in the theme and point to the range.
And then the Button can use the variable like this:
Pros
Cons
Option 2: Use opacity
Use opacity instead of using different hue when the component state changes. Meaning, the base color is the same but with different opacity. Example:
The example above can reduce some variables compared to the first approach. The default theme can look like this:
Opacity scale can be used to have consistency between components.
This approach can be applied in other components as well.
Cons
221 209 250
. As of now, this is unavoidable due to the limitation of CSS.contained
variant in "Channel + Opacity" section)Beta Was this translation helpful? Give feedback.
All reactions