Support resolving object-based tokens to base CSS values in style() for better design token ergonomics #1681
mariuslundgard
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all 👋
I wanted to open a discussion about improving the ergonomics of consuming design tokens with vanilla-extract, specifically when tokens are represented as objects with both a “base value” and nested variants.
Context / Problem
Many design systems expose token APIs where a token group has a base value and variants, for example:
This shape is useful because:
color.fgandcolor.fg.mutedsemantics,default.However, in vanilla-extract today, passing an object token like
vars.color.fgintostyle()isn’t supported directly because it’s not a string. This leads to workarounds such as forcing a.base/defaultkey, inverting the object hierarchy, or abandoning a clean grouped API entirely.What I’d love to see is:
Why this matters
defaultnaming.The idea is not to change the runtime output or core CSS API — just to enrich how
style()(and similar consumers) accept a token object by resolving it to its base string when appropriate.Possible user experience
vars.color.fg,vars.color.fg.muted,vars.color.fg.link).Questions / open points
$orvalue)?style()?Happy to iterate on the details — thanks for considering it! 🙏
Beta Was this translation helpful? Give feedback.
All reactions