feat: rework base theming architecture - #21
Merged
Merged
Conversation
mellyeliu
commented
Jan 22, 2026
|
|
||
| StyleX has limited support for combined pseudo-selectors like `:hover::after` or `:active::after`. | ||
|
|
||
| **Problem**: Tried using `::after` pseudo-element for hover/active overlay effects: |
Member
Author
There was a problem hiding this comment.
this does in fact work within StyleX, although it's a bit hacky
cixzhang
reviewed
Jan 22, 2026
cixzhang
reviewed
Jan 22, 2026
cixzhang
reviewed
Jan 22, 2026
cixzhang
reviewed
Jan 22, 2026
mellyeliu
force-pushed
the
theme-test
branch
2 times, most recently
from
January 24, 2026 00:02
9f7791f to
da251c8
Compare
mellyeliu
marked this pull request as ready for review
January 24, 2026 00:04
mellyeliu
marked this pull request as draft
January 24, 2026 00:04
- Split rawTokens into separate *Raw objects (colorRaw, spacingRaw, etc.) - Use `as const satisfies Record<*VarName, string>` for type safety - Add Base*Raw type exports for cleaner createTheme casting - Replace `as any` with `as unknown as Base*Raw` in theme files - Export Base*Raw types from theme index for external use
- Update component styles to use theme tokens - Update storybook stories for consistency - Clean up layer, layout, and container components
Member
Author
cixzhang
approved these changes
Jan 24, 2026
cixzhang
left a comment
Contributor
There was a problem hiding this comment.
Nice! Thanks for updating this and making the theming system better!
I guess we didn't want to prefix with --xds? Maybe something we can revisit later or perform prefixing using a plugin if we end up white gloving this system. I do like the conciseness.
Member
Author
|
Yeah, I mainly left out the prefix for now in case the naming discussions weren't stabilized. We can always update or tweak it later! |
czarandy
pushed a commit
that referenced
this pull request
Jan 26, 2026
* feat: rework base theming architecture with typed createTheme - Split rawTokens into separate *Raw objects (colorRaw, spacingRaw, etc.) - Use `as const satisfies Record<*VarName, string>` for type safety - Add Base*Raw type exports for cleaner createTheme casting - Replace `as any` with `as unknown as Base*Raw` in theme files - Export Base*Raw types from theme index for external use * refactor: clean up component styles and stories - Update component styles to use theme tokens - Update storybook stories for consistency - Clean up layer, layout, and container components
cixzhang
pushed a commit
that referenced
this pull request
Apr 26, 2026
* feat: rework base theming architecture with typed createTheme - Split rawTokens into separate *Raw objects (colorRaw, spacingRaw, etc.) - Use `as const satisfies Record<*VarName, string>` for type safety - Add Base*Raw type exports for cleaner createTheme casting - Replace `as any` with `as unknown as Base*Raw` in theme files - Export Base*Raw types from theme index for external use * refactor: clean up component styles and stories - Update component styles to use theme tokens - Update storybook stories for consistency - Clean up layer, layout, and container components
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Reworking the general theming infrastructure from #16
The theming flow looks something like this:
defineConstscalls.defineConststranspiles to a plain JS object that is inlined at build time, generates no CSS, and its values can be imported and used withinstylex.createorstylex.defineVarsfiles as needed.createcalls and we don't care about repeating across files. But it'll get messydefineVarsuses thedefineConstsvalues and--keys, which expose the variable name and allow users to modify them as CSS variables anywhere.There are two primary issues to using create/props instead of defineVars/createTheme in #16
1, Losing the VarGroup guarantee that each theme sets all variables (and unset keys are reset)
2. It creates a single class to set all variables and not one class per variable. (performance critical)
Blockers/Todos
One option is to also use
--keys in defineConsts as well instead of the camelCased key for ease of use. Currently we disallow such keys indefineConstsfor relatively arbitrary (safety/obfuscation) reasons but opening facebook/stylex#1460 as an option to fix thisWe could have a system that maps cleanly from defineVars -> defineCosts (one camel cased, another --)
Testing
Storybook theming works
Screen.Recording.2026-01-23.at.9.28.25.PM.mov