feat(theme): variants carry their own styles - #803
Merged
Conversation
Changes the variants input from string arrays to style objects:
// Before
variants: { button: ['primary-muted'] }
// After
variants: {
button: {
'primary-muted': {
backgroundColor: 'var(--color-accent-muted)',
color: 'var(--color-accent)',
},
},
}
Declaration and styles live together. Empty {} registers the variant
name without adding styles.
defineTheme merges variant styles into components as variant: keys,
so the CSS generation path is unchanged. The output variants field
stays as string[] for CLI type augmentation compatibility.
Explicit component overrides take precedence over variant styles
on collision (deepMergeComponents).
Part of #802 — unified defineTheme API.
Co-authored-by: Navi <navi@navibot.dev>
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
rubyycheung
added a commit
that referenced
this pull request
Mar 22, 2026
Migrate to the unified defineTheme API from #803/#804: - typeScale → typography.scale + typography roles (body/code) Fonts now declared via typography config instead of raw --font-* tokens - motionScale → motion - variants: string[] → Record<string, styles> Custom button variant styles moved from components into variants (declaration + styles together) - CLI: fix generateVariantDeclarations to handle new object-style variants alongside legacy array format
Merged
cixzhang
added a commit
that referenced
this pull request
Apr 26, 2026
cixzhang
added a commit
that referenced
this pull request
Jun 21, 2026
cixzhang
added a commit
that referenced
this pull request
Jun 21, 2026
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.
Changes the
variantsinput from string arrays to style objects — declaration and styles live together.What changed:
variantsinput type:Record<string, string[]>→Record<string, Record<string, Record<string, string>>>defineThemeextracts variant names for type augmentation (output staysstring[])componentsasvariant:keys — CSS generation unchanged{}registers the name without stylescomponentsoverrides win on collisionWhy: Declaring a variant in one place and styling it in another (
components) meant you could forget one side. Now they're co-located.componentsstays for overriding existing built-in variants.Part of #802.