Skip to content

feat(badge): add color-based variants and deprecate semantic variants#327

Open
nandanmen wants to merge 9 commits intocloudflare:mainfrom
nandanmen:nanda/badges
Open

feat(badge): add color-based variants and deprecate semantic variants#327
nandanmen wants to merge 9 commits intocloudflare:mainfrom
nandanmen:nanda/badges

Conversation

@nandanmen
Copy link
Copy Markdown
Contributor

@nandanmen nandanmen commented Mar 27, 2026

Summary

  • Add color-based Badge variants: red, orange, yellow, green, teal, blue, neutral, inverted
  • Add subtle variants for each color (red-subtle, orange-subtle, etc.) with lighter backgrounds and darker text
  • Retain outline and beta variants unchanged
  • Deprecate primary (use inverted), secondary (use neutral), destructive (use red), success (use green) with backwards-compatible aliases
  • Dark mode support: subtle variants flip to dark backgrounds with light text, regular color variants darken slightly, inverted flips to white bg with black text
  • Default variant changed from primary to neutral
  • Update docs site demos and MDX page
CleanShot 2026-03-27 at 13 19 30@2x CleanShot 2026-03-27 at 13 19 33@2x

nandanmen and others added 3 commits March 27, 2026 13:11
Replace primary/secondary/destructive/success/outline/beta with color
variants (red, orange, yellow, green, teal, blue, neutral, inverted)
plus subtle variants for each color. Includes dark mode support with
flipped subtle colors, darkened regular variants, and inverted flip.
…ariants

Add back outline and beta variants unchanged. Add deprecated primary,
secondary, destructive, and success variants mapped to their new color
equivalents for backwards compatibility. Update changeset and docs.
},
"green-subtle": {
classes:
"bg-emerald-100 text-emerald-800 dark:bg-emerald-900 dark:text-emerald-200",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be a lint rule that prevents writing dark: classes.

for theming to work, we need vars

Copy link
Copy Markdown
Collaborator

@geoquant geoquant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • demo labels to match the variant blue => "Blue Subtle"
  • remove dark: classes and creating new variables

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 28, 2026

npm i https://pkg.pr.new/@cloudflare/kumo@327

commit: 09aa85b

…tic tokens

Add badge color tokens to theme-generator config for all color variants
(red, orange, yellow, green, teal, blue, neutral, inverted) and their
subtle counterparts. Tokens use light-dark() so dark mode is automatic
without dark: prefix.

- 13 new color tokens (kumo-badge-*) for backgrounds
- 8 new text-color tokens for subtle variant text and inverted text
- Updated badge.tsx to reference semantic classes (bg-kumo-badge-*, text-kumo-badge-*)
- Deprecated variants (primary, secondary, destructive, success) also updated
- Passes lint (0 errors), typecheck, and all 676 tests
- Rewrote vite-plugin-kumo-colors to use ssrLoadModule in dev mode,
  reading the source config.ts directly instead of the built dist/.
  No more stale tokens when editing theme-generator config — changes
  appear on the docs color page without rebuilding kumo.
- Added theme-generator aliases to kumo-hmr plugin for completeness.
- Removed kumo-badge-neutral-subtle color token (duplicate of kumo-fill).
  Badge neutral-subtle variant now uses bg-kumo-fill instead.
Automatically groups component-level tokens (e.g. kumo-badge-*)
under a new 'Component Colors' section on the /colors docs page.

Detection is dynamic — uses the component registry to identify token
names matching the pattern kumo-{component}-{variant}. Requires at
least 2 segments after 'kumo-' to avoid false positives on standalone
semantic tokens like kumo-link or kumo-surface.

Currently shows Badge (22 tokens). As other components add their own
color tokens following the same naming convention, they'll appear
automatically without code changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants