Color
Components: Alert, AlertTitle, Badge, Banner, Button, Card, CardContent, Drawer
+9 more
DropdownMenu, Link, Popover, Radio, SegmentedControl, Slider, Tag, Text, ThemeProvider
Use semantic tokens; all but -fixed switch with the theme. The prefix repeats: bg-bg-surface-1, text-text-primary.
What you use
Rules
Surfaces
- If it sits in page flow (
Card), usebg-bg-surface-1. - If it floats over content (
Popover,DropdownMenu,Drawer), usebg-bg-surface-2. - If it is a raised thumb or indicator (
Slider,SegmentedControl,Radio), usebg-bg-surface-3. - If it is a control track, use
bg-bg-primary, neverbg-bg-surface-3. - Use
bg-bg-surface-5only for a raised strip likeBanner. - Pick the level by elevation: levels 1–4 are all white in light. Separate them with borders and shadows.
Status
- If the area holds dark text, use
bg-bg-light-<status>orbg-bg-<status>withborder-border-<status>. - If it holds
text-text-primary-alt, usebg-bg-fill-<status>. - Use
brandonly for the primary action,aionly for assistant content. - Pair status color with an icon or word.
- Use
dangerfor errors.destructiveis only anAlert/Buttonprop andring-focus-destructive.
States
- Transparent item:
hover:bg-states-primary-hover,active:bg-states-primary-pressed. Selected:bg-states-primary-active. - Solid fill: add
overlay, thenhover:overlay-states-on-fill-hover,active:overlay-states-on-fill-pressed. - Brand/danger item:
bg-states-brand-*,bg-states-danger-*. Inverted surface:bg-states-primary-alt-*. states-*tokens are translucent layers over a resting fill.- Prefer components with built-in states, like
Button.
Theme
- Switch themes with
useTheme().setTheme(), never by settingdata-theme. - Use
-alttokens on inverted surfaces;-fixedtokens only on fixed surfaces. - Never use the
dark:variant. It follows the OS, notThemeProvider. - Never use raw palette classes (
bg-red-500), which ignore the theme, or opacity modifiers (/90). - Never reuse
bg-component-*outside its component. Exception: an auth page paintsbg-component-app-shell-bg; see Auth page. - Never edit
--color-syntax-*mappings.
These do not exist
bg-primary,text-primary,border-primary→bg-bg-primary,text-text-primary,border-border-primary.text-muted,text-subtle,text-disabled→text-text-secondary,text-text-hint,text-text-disable-primary.bg-surface,bg-card,bg-background,bg-muted→bg-bg-surface-1,bg-bg-light-primary.bg-bg-surface-0,bg-bg-surface-6→ levels run 1–5.errortokens →danger.bg-bg-fill-primary→ no neutral solid fill.border-border-secondary→border-border-primary-light.Badgecolor='purple'→violet.Taghas nocolorprop.
Examples
A soft danger box in a card.
Notices and labels are components.
A custom solid fill keeps its color on hover.
Switch themes with useTheme.
Reference
<status>: brand, danger, warning, success, info, ai.
<family>: primary, primary-alt, or a <status>. Text color: primary, primary-alt, secondary, secondary-alt, tertiary-alt, danger, inherit. Badge color: slate, gray, zinc, neutral, stone, red, w-orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, fuchsia, pink, rose.