Token Names
How color token names are built, and how each role gets its color when a theme family is made.
A color token is named for its role, not its color: --primary, not
--blue-600. Changing the family or primary color changes the values, and
every name stays the same. The Color Tokens page
lists every token with its value.
Neutral roles
Neutral roles keep shadcn's names, so code written for shadcn reads the same tokens. A surface and the text on it share a stem:
--cardis the surface, and--card-foregroundis text on it.--sidebar-*repeats the set for the sidebar.--borderis for dividers and decoration, with no contrast minimum.--inputis the border of a form control, held to 3:1.--fieldis the background of a form control, set by the style rather than the family.
Each family maps its neutral roles by hand to palette colors, such as
zinc-950 or white at 10% opacity. Zinc's map:
| Token | Description | Zinc light | Zinc dark |
|---|---|---|---|
--background | The page background. | white | zinc-950 |
--foreground | Default text on background. | zinc-950 | zinc-50 |
--card | Card surface. | white | zinc-900 |
--card-foreground | Text on card. | zinc-950 | zinc-50 |
--popover | Popover, menu and dialog surface. | white | zinc-900 |
--popover-foreground | Text on popover. | zinc-950 | zinc-50 |
--secondary | Neutral fill for secondary actions. Stays neutral whichever primary is chosen. | zinc-100 | zinc-800 |
--secondary-foreground | Text on secondary. | zinc-900 | zinc-50 |
--muted | Muted surface for secondary content. | zinc-100 | zinc-800 |
--muted-foreground | Secondary text, on muted or background. | zinc-600 | zinc-400 |
--accent | Subtle surface for hovered and highlighted items. Menu item hover, selected list row. | zinc-100 | zinc-800 |
--accent-foreground | Text on accent. | zinc-900 | zinc-50 |
--border | Dividers and decorative outlines. Not for the sole boundary of an interactive control. | zinc-200 | white / 10% |
--input | Border of form controls. | zinc-500 | zinc-500 |
--sidebar | Sidebar surface. | zinc-50 | zinc-900 |
--sidebar-foreground | Text on sidebar. | zinc-950 | zinc-50 |
--sidebar-accent | Hovered item in the sidebar. | zinc-100 | zinc-800 |
--sidebar-accent-foreground | Text on sidebar-accent. | zinc-900 | zinc-50 |
--sidebar-border | Dividers inside the sidebar. | zinc-200 | white / 10% |
--field | Background of form controls, set by the style. | transparent | --foreground / 4.5% |
Intent roles
Each of the five intents, primary, destructive, success, warning and
info, gets the same set of roles. The bare intent name is the solid fill,
and a suffix names the rest:
| Token | Description | Step |
|---|---|---|
--{intent} | Solid fill, such as a button background. | The step nearest the scale's anchor whose foreground passes 4.5:1 and which passes 3:1 on the page |
--{intent}-hover | The solid fill when hovered or pressed. | The fill's neighbor away from the foreground, else its other neighbor: the first that passes 4.5:1 with the foreground |
--{intent}-subtle | Soft tinted background. | 50 in light, 950 in dark |
--{intent}-border | Tinted outline, for soft badges and alerts. Decorative; not a control boundary. | 200 in light, 800 in dark |
--{intent}-text | Intent-colored text on the page. Links, outline buttons, soft badges. | From 600 in light, 400 in dark, the first step away from the page that passes 4.5:1 on the page and on subtle, pressed too |
--{intent}-foreground | Text and icons on the solid fill. | Step 50 or 950, whichever contrasts more with the fill |
The family chooses each intent's color, and you can change the primary. The
steps aren't fixed: the generator picks them for each color and flavor by
contrast, so --primary isn't the same step in every scale or flavor.
Scales
Each intent also exposes its whole scale, --primary-50 to --primary-950,
for the rare color no role covers. Prefer a role: a step keeps its value
when the flavor changes, so text on it can fail contrast in dark mode.
Derived roles
shadcn names a few roles that follow another token rather than a palette color:
| Token | Follows | Description |
|---|---|---|
--ring | --primary-text | Focus ring. Follows primary-text, which passes 3:1 on the page, cards and popovers. |
--sidebar-primary | --primary | Primary fill inside the sidebar. |
--sidebar-primary-foreground | --primary-foreground | Text on sidebar-primary. |
--sidebar-ring | --primary-text | Focus ring inside the sidebar. |
Focus rings follow --primary-text rather than --primary: the fill only
has to pass 3:1 on the page, and fails it on dark cards and popovers.
Charts
--chart-1 to --chart-5 color data series. Every family reads five steps
of the primary color's scale; Zinc's:
| Token | Description | Zinc's color |
|---|---|---|
--chart-1 | First chart series. Data series; a family chooses a ramp or categorical hues. | Step 300 of the primary scale |
--chart-2 | Second chart series. Data series; a family chooses a ramp or categorical hues. | Step 500 of the primary scale |
--chart-3 | Third chart series. Data series; a family chooses a ramp or categorical hues. | Step 600 of the primary scale |
--chart-4 | Fourth chart series. Data series; a family chooses a ramp or categorical hues. | Step 700 of the primary scale |
--chart-5 | Fifth chart series. Data series; a family chooses a ramp or categorical hues. | Step 800 of the primary scale |
Contrast
Every family, flavor and primary color passes these pairs, which the token
package checks in its tests. Decorative pairs, such as --border on the
page, have no minimum.
| Text | Background | Minimum |
|---|---|---|
--foreground | --background | 4.5:1 |
--card-foreground | --card | 4.5:1 |
--popover-foreground | --popover | 4.5:1 |
--secondary-foreground | --secondary | 4.5:1 |
--muted-foreground | --muted | 4.5:1 |
--muted-foreground | --background | 4.5:1 |
--accent-foreground | --accent | 4.5:1 |
--sidebar-foreground | --sidebar | 4.5:1 |
--sidebar-accent-foreground | --sidebar-accent | 4.5:1 |
--primary-foreground | --primary | 4.5:1 |
--primary-foreground | --primary-hover | 4.5:1 |
--primary-text | --background | 4.5:1 |
--primary-text | --primary-subtle | 4.5:1 |
--primary | --background | 3:1 |
--destructive-foreground | --destructive | 4.5:1 |
--destructive-foreground | --destructive-hover | 4.5:1 |
--destructive-text | --background | 4.5:1 |
--destructive-text | --destructive-subtle | 4.5:1 |
--destructive | --background | 3:1 |
--success-foreground | --success | 4.5:1 |
--success-foreground | --success-hover | 4.5:1 |
--success-text | --background | 4.5:1 |
--success-text | --success-subtle | 4.5:1 |
--success | --background | 3:1 |
--warning-foreground | --warning | 4.5:1 |
--warning-foreground | --warning-hover | 4.5:1 |
--warning-text | --background | 4.5:1 |
--warning-text | --warning-subtle | 4.5:1 |
--warning | --background | 3:1 |
--info-foreground | --info | 4.5:1 |
--info-foreground | --info-hover | 4.5:1 |
--info-text | --background | 4.5:1 |
--info-text | --info-subtle | 4.5:1 |
--info | --background | 3:1 |
--ring | --background | 3:1 |
--ring | --card | 3:1 |
--ring | --popover | 3:1 |
--sidebar-ring | --sidebar | 3:1 |
--input | --background | 3:1 |
--destructive-text | --background | 3:1 |
--input | --card | 3:1 |
--destructive-text | --card | 3:1 |
--input | --popover | 3:1 |
--destructive-text | --popover | 3:1 |