Replies: 1 comment
-
The only solution I can think of, if you’re using the default StyleX hashed variable names, is that you would point your hashed variable to a named variable ( |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Heyo everyone,
We’re starting to introduce customization capabilities into our design system, with a small, focused goal: allowing users to choose their primary color.
Background
Currently, we have a library of tokens built with defineVars, where we use readable string keys as the names, as requested by our design team.
We also define semantic tokens that point to core tokens to provide an abstraction layer:
The Challenge
We want to enable users to dynamically change the primary color at runtime (e.g., based on API data or user preference).
I’ve looked into using createTheme, but it seems to be intended for static values known at build time. Since our customization might come from an API or user settings, this approach doesn’t seem feasible.
One potential solution I’ve considered is directly updating the CSS variables at the html or body tag level. Since we use named variables rather than hashed ones, this might be manageable. However, it feels a bit off given StyleX’s default behavior of hashing variable names, and I wonder if there’s a more “StyleX-native” way to handle this.
Also, I’d like to avoid using inline style attributes.
Question
Has anyone tackled dynamic theme customization with StyleX, especially where the colors are not known until runtime? Are there best practices or recommended approaches for this kind of use case?
Any guidance or examples would be greatly appreciated!
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions