Replies: 3 comments 9 replies
-
@janhassel love this exploration! Zones/inline themes are definitely an artifact of the Duo exploration days that we never were really able to tackle in v10. I think that, unfortunately, some designs may still use this idea of "themes in themes" and the resulting compromise was the Ultimately you're totally right, CSS Custom Properties in this space would be ideal. It would allow us to solve this cleanly and efficiently and would require no re-write of the components themselves. It would just work. The mechanism for this may end up just being theme classes, and for the developer that may end up looking like: <Theme value="white">
<PageSection />
<Theme value="g10">
<PageSection />
</Theme>
<PageSection />
</Theme> Or more simply the following theme classes: Curious what you think of this @janhassel and if anything is missing based on the use-cases you described above. |
Beta Was this translation helpful? Give feedback.
-
We have actually been working on updating our design tokens for "v11." We initially were intending to build out a structure to better support the "light" variants in each theme and address some of these layering issues you have pointed out (we were calling that solution the "alt" tokens). BUT if we can implement this "inline theming" then we can rethink the new tokens with that in mind. |
Beta Was this translation helpful? Give feedback.
-
@janhassel not sure if you've seen this discussion #7743. It's related to the issue you bring up here, and @aagonzales proposes 2 solutions. |
Beta Was this translation helpful? Give feedback.
-
Related: #4358 (comment), #2912, #4826, #5598, #5914
When using tiles / cards / containers to layout an interface, it quickly becomes challenging to apply the correct theming to all elements due to the overlaps in some color tokens. Having a container that uses
ui-01
as its background requires all inputs inside to useprops.light
in order to switch their background color fromfield-01
tofield-02
. Support forprops.light
is not given for all components though. The DataTable for example does not offer this prop and can therefore not be correctly displayed within aui-01
container.One solution to this is to apply different themes to different zones. One could create a
g10/ui-01
container and then emit thewhite
theme to its content, effectively treating the inside of the container as it would be a page usingwhite
. This would correctly render all components without usingprops.light
and therefore supports the DataTable. However, this solution can also become tricky when nesting more objects and adds a lot of duplicates to the code.From a developer experience standpoint it would be great if the components just "knew" how to render properly and in which context they are. One approach could be to introduce utility classes (@joshblack I believe you were exploring this direction before) that would emit only the necessary updated color tokens for their content.
Example
An input component would no longer use
field-01
as its background and have a light variant to switch tofield-02
but it would rather rely on a context-aware tokenfield
. By default,field
could be set tofield-01
.To make a container, developers would use a utility class, let's call it
cds-bg-ui
. This class would set the container's background color toui
(also context-aware) and override relevant color tokens for its content.In this example, we'd want to use
field-02
for all inputs. Any nested container should then useui-02
as their background and revert tofield-01
for its inputs.(Since there are only ui-01 and ui-02 that describe a container background in the color usage guidelines, I assume it's a design choice to not encourage more deeply nested levels)
A developer would then not need to care about where components are rendered and if they might need any additional props.
Quick codepen example applying above described behaviour: https://codepen.io/janhassel/pen/7f593afc5cac9c7e9f94f506850e54b1?editors=1100
I think an approach like this could vastly improve the developer experience and make sure colors are used as intended (avoid having field colors and background colors the same or wrong usage of zoned themes). I have to say that I didn't work a lot with css frameworks like tailwind and this idea of context-awareness might not fit into the "only-one-rule-and-nothing-more" mindset. It would definitely make the styling more opinionated, although that might be a good thing for a design system (to ensure correct usage).
Would love y'all's thoughts on this.
Beta Was this translation helpful? Give feedback.
All reactions