Repository navigation
Description
Summary
XDSBadge currently only supports semantic color variants (neutral, info, success, warning, error). We need to add non-semantic color variants to match the internal docs tool reference and darken the grey used for the neutral variant.
Reference: [internal link removed]
What needs to change
1. Add non-semantic color variants
The internal docs tool Badge supports a broader set of color options beyond semantic meaning. We should add variants like:
bluepurplepinktealcyanorangeyellowgraygreenred
These are useful when badges are used for categorization, tagging, or labeling where the color does not carry semantic meaning (e.g. team labels, category tags, filter chips).
2. Darken the neutral grey
The current neutral variant uses --color-deemphasized which is only ~5% opacity in light mode (#0536590C). It should use --color-gray-background (#0A131733, ~20% opacity) for better visual contrast matching the internal docs tool reference.
Suggested implementation
The token system already has all the non-semantic color sets (--color-{color}-background and --color-{color}-text). The fix maps directly to existing tokens — no new tokens needed.
// In XDSBadge.tsx — add non-semantic variants using existing color tokens
const variants = stylex.create({
// Semantic variants (existing)
neutral: {
backgroundColor: colorVars['--color-gray-background'], // was --color-deemphasized (too light)
color: colorVars['--color-text-primary'],
},
info: {
backgroundColor: colorVars['--color-accent'],
color: colorVars['--color-text-on-media'],
},
success: {
backgroundColor: colorVars['--color-positive'],
color: colorVars['--color-text-on-media'],
},
warning: {
backgroundColor: colorVars['--color-warning'],
color: colorVars['--color-text-primary'],
},
error: {
backgroundColor: colorVars['--color-negative'],
color: colorVars['--color-text-on-media'],
},
// Non-semantic color variants (new)
blue: {
backgroundColor: colorVars['--color-blue-background'],
color: colorVars['--color-blue-text'],
},
cyan: {
backgroundColor: colorVars['--color-cyan-background'],
color: colorVars['--color-cyan-text'],
},
gray: {
backgroundColor: colorVars['--color-gray-background'],
color: colorVars['--color-gray-text'],
},
green: {
backgroundColor: colorVars['--color-green-background'],
color: colorVars['--color-green-text'],
},
orange: {
backgroundColor: colorVars['--color-orange-background'],
color: colorVars['--color-orange-text'],
},
pink: {
backgroundColor: colorVars['--color-pink-background'],
color: colorVars['--color-pink-text'],
},
purple: {
backgroundColor: colorVars['--color-purple-background'],
color: colorVars['--color-purple-text'],
},
red: {
backgroundColor: colorVars['--color-red-background'],
color: colorVars['--color-red-text'],
},
teal: {
backgroundColor: colorVars['--color-teal-background'],
color: colorVars['--color-teal-text'],
},
yellow: {
backgroundColor: colorVars['--color-yellow-background'],
color: colorVars['--color-yellow-text'],
},
});The type XDSBadgeVariant = keyof typeof variants updates automatically — no manual type changes needed.
Key design notes
- Non-semantic badges use tinted backgrounds + colored text (subtle style), while semantic badges use solid backgrounds + white text (bold style). This matches the internal docs tool pattern where non-semantic colors are softer.
neutralfix: swap--color-deemphasized→--color-gray-backgroundfor darker grey.- No new tokens required — everything maps to existing
--color-{color}-backgroundand--color-{color}-texttokens.
Affected files
packages/core/src/Badge/XDSBadge.tsx— add new variant styles (neutral fix + non-semantic colors)packages/core/src/Badge/XDSBadge.test.tsx— tests for new variantsapps/storybook/stories/Badge.stories.tsx— add stories for non-semantic variants
Current variants
neutral | info | success | warning | error
Proposed variants
neutral | info | success | warning | error | blue | cyan | gray | green | orange | pink | purple | red | teal | yellow
Activity
rubyycheung commentedon Feb 21, 2026
@cixzhang Why was the non-semantic colors not added?
cixzhang commentedon Feb 22, 2026
Badges were added as part of a test for the PR enrichment flow so likely need refinements.
You can reference the token now for non semantic colors.
feat(badge): add non-semantic color variants and darken neutral grey
feat(badge): add non-semantic color variants and darken neutral grey
feat(badge): add non-semantic color variants and darken neutral grey
feat(badge): add non-semantic color variants and darken neutral grey
cixzhang commentedon Mar 8, 2026
We need a secondary token for buttons tokens and these default badges
cixzhang commentedon Mar 26, 2026
Merged into #719 (Cindy's Components — Badge section). Non-semantic color variants tracked there.
feat(Badge): add non-semantic color variants
feat(Badge): add non-semantic color variants
feat(Badge): add non-semantic color variants
feat(Badge): add non-semantic color variants