Color

A token names a role; the user's theme picks the colour. Every surface, line and text reads one.

Draw with the tokens, never with a colour. bg-card, text-muted-foreground and border say what a thing is; the theme the user picked says what colour that is, in light, in dark, and in each of the palettes they can pick.

A merge box like the pull request demo's, its card in the danger intent. Nothing in it names a colour: the card, the failed check and the passed ones all read a token. Pick another theme from the top bar and the box follows, as does every swatch on this page, values and contrast included.

Surfaces and their text#

Each surface comes with the foreground meant for text on it. Put text on a surface in that surface's foreground, or in muted-foreground for the secondary line. The number on each swatch is the contrast of the pair in the theme you are looking at.

Aa
background / foreground
Aa
background / muted-foreground
Aa
card / card-foreground
Aa
popover / popover-foreground
Aa
muted / muted-foreground
Aa
sidebar / sidebar-foreground
Aa
primary / primary-foreground
Aa
secondary / secondary-foreground
Aa
accent / accent-foreground
The thingSurfaceText
The pagebg-backgroundtext-foreground
A secondary line, a timestamp, a hint—text-muted-foreground
A card, a panel set off from the pagebg-cardtext-card-foreground
A menu, popover, dialog or sheetbg-popovertext-popover-foreground
A well, a quiet fillbg-mutedtext-muted-foreground or text-foreground
A name from code in a sentence: an InlineCodebg-code, the ink laid thin over whatever it sits ontext-code-ink, the line's own colour with a little ink
A sidebar set beside the rest on one sheet, as an app's is below mdbg-sidebartext-sidebar-foreground
The one main action in viewbg-primarytext-primary-foreground
What the primary marks as on: a box ticked, a radio chosen, a switch on, a slider's runbg-primarytext-primary-foreground
What the primary marks as current: a nav's current placebg-tint, the primary's tinttext-tint-ink
A second action beside it: a secondary buttonbg-tint, edged in border-tint-edgetext-tint-ink
A key: an outline button, a select, a toggle, a chosen segmentbg-key, edged in border-key-edgetext-foreground
A hovered, highlighted or open row, with a state-cue tick on its leading edgebg-accenttext-accent-foreground
A list box's or a table's picked row: no fill, a pick-cue bar of the primary on its leading edge—text-foreground
Something the user has set that is in force: a Badge variant="marker"bg-markertext-primary

The marker's colours mark one thing: something the user has set that is in force, such as the count a toolbar's ⋯ shows of the filters in use inside it. That is a Badge variant="marker", edged in a tint of the accent, so it reads beside the one main action without competing with its fill.

Inbox

The Mail demo in miniature, on the surfaces in the table: the folders on the app's ground with no fill of their own (on sidebar below md, where the app is one sheet), Compose on primary, the current folder in the primary's tint, the open conversation on accent, names and dates on the page's foreground and muted-foreground, a code span in bg-code, and More actions opening on popover. The merge box above is the card. On a phone the folders hide, as they do in the demo.

The components already make these choices: a Card is bg-card, a Button is bg-primary, and a Pane decides when a sidebar is bg-sidebar (Surfaces). Reach for the tokens yourself for the surfaces you build.

Selected text#

Aa
selection / selection-foreground

Text the user selects is drawn in selection-foreground on selection, on every surface: the page, a card, a menu, a field and an editor alike. The base layer sets it once, so leave ::selection alone in what you build; a coloured span, a link or a muted line turns selection-foreground while selected, so the selection reads as one run. The fill stands off the page, the cards, the popovers, muted and the sidebar, and its text keeps 4.5:1 on it. A terminal is the exception: an ANSI log and a cast player select in terminal-selection and keep their ANSI colours, as a terminal does.

Lines and focus#

border
input
ring

border separates; input outlines a field; ring draws focus. input is the darker of the two lines: it is the edge an empty field, an unchecked checkbox and a switch's off track are found by, so it keeps 3:1 against the page, a card and a popover, where border only has to be seen beside what it divides. The themes used as published keep their own edges, a few of them lighter; Accessibility lists them, and its contrast table measures the theme you are in. Outline a control you build in input, and divide in border. The base layer gives every element border-border, so a bare border class is already the right colour. A line is the quietest way to separate two things, and space is quieter still: prefer a gap to a rule where the grouping reads without one.

Meaning#

destructive is for what deletes, removes or fails, and for nothing else; a red that means "important" teaches people to ignore the red that means "gone".

destructive
success
warning
diff-addition
diff-deletion
chart-1
chart-2
chart-3
chart-4
chart-5
  • success is for what finished as it should: a passed run, a saved change, a check that holds. warning is for what wants the reader before it can go on: a question waiting on their answer, or what still works but needs a look, such as stale data, a value that passes only for large text or an input the app guessed at. Like destructive, each is drawn as text, an icon or a border, or as a tint of itself (Badge intent="success"). A frame or a card in an intent is edged in it, its lid or header takes the tint and what it holds a fainter wash, under words in the colour's ink (Surfaces). The one solid fill of a status colour is a button's whose intent makes a verdict the action its view is for, as Actions & buttons describes.
  • diff-addition and diff-deletion are the added and removed lines of a diff, the colours a reader already knows from code review. A diff uses them and nothing else does; a passed run is success.
  • chart-1 to chart-5 are series in a chart, in order, each held to 3:1 against the page. They tell series apart; they carry no meaning of their own.
  • There is no info token. Neutral news needs no colour: write it in foreground or muted-foreground, with an icon if it has to stand out.

Colour is never the only signal. A state shown only as a red or green dot is invisible to a colour-blind reader and to anyone in a palette where the two are close (WCAG 1.4.1). Pair it with a word, an icon, or both.

  • Lint Passed
  • Build Passed
  • Test Failed
Do

Say the state, and let the colour back it up.

  • Lint
  • Build
  • Test
Don't

Show a state as a colour alone, and in a hard-coded red that no theme can change.

Tags#

tag-red
tag-orange
tag-yellow
tag-green
tag-teal
tag-blue
tag-purple
tag-pink
tag-gray

A tag, the label a user puts on a task or a conversation, takes one of 9 named colours: Badge variant="marker" with a color writes its name in the colour, on a light fill of its own colour. Like the chart series, the colours tell tags apart and say nothing themselves: a red tag is not an error, and the accent still marks only where the user is and what they can do. Every theme keeps each colour's hue, so a blue tag is blue whichever theme the user picks, and sets its lightness so the name holds 4.5:1 on its own fill. Where tags are set among an item's own words, a card's on a board, variant="dot" draws each as a dot of its colour before its name, so the item's title still leads.

color="red"
bugcidocsdesignperfrelease
autoTagColor(id)
bugcidocsdesignperfrelease
color="#d73a4a"
bugcidocsdesignperfrelease
  • The colour the app stores. Where people pick a tag's colour, store what they picked and pass it to color: one of the names, or any colour value, such as one an import from a forge brings. A value is drawn at its own hue from the theme's colours, so GitHub's #d73a4a stays a red that reads in every theme.
  • A colour from the tag. Where tags have no colour of their own, autoTagColor(id) picks one from the tag's id, the same one everywhere. Give it the id, not the name on screen, which a rename or a translation changes. autoTagColor never picks gray, which is left for a tag meant to have no colour at all.
  • autoTagColor's colours repeat soon, and a handful of tags will share one. Where every tag must look apart, store a colour for each.

The name is the tag; the colour only helps the eye find it. Wherever a tag is picked, in a filter's menu, a sidebar or a Select, draw the tag itself, as the list does, so the colour that finds it in the list finds it where it is chosen.

Tints#

What is pressed or on in the primary is the primary itself, its words and marks reversed out of it: the primary Button, a box ticked, a radio chosen, a switch that is on and a slider's run. A tint of a primary with no hue is one more grey, and stands too close to off for on to read. A place that is current, which is read rather than pressed, is tinted instead: bg-tint under the words in text-tint-ink, the primary held dark enough on light, and light enough on dark, to read on the tint in every palette.

The secondary button is the one tint that is pressed. It is edged in the primary (border-tint-edge), which ranks it between the solid primary and a grey key, and it steps as a key does: more of the primary under the pointer (bg-tint-hover), more again held down (bg-tint-held; on dark, back toward the card). A button's or a segment's intent stands a status colour in for the primary, and every one of these looks follows it: the solid, the tint, its edge and its ink.

The grey keys, from an outline button to a chosen segment, are not quite grey: each is a step of lightness from the card, in the page's own hue. A palette whose cards are white and whose page is cream draws cream keys, which sit in the page rather than on it. The theme store writes the page's chroma and hue beside the tokens for them, so a theme of your own needs nothing more.

A token takes an opacity: bg-primary/10, bg-destructive/20. That is how a tint stays in the theme. Text on a tint of its own colour is where contrast fails first, so a component that sets destructive text on a destructive tint mixes the foreground in, text-[color-mix(in_oklab,var(--destructive),var(--foreground)_65%)], as Badge does; a button in a status colour writes its words in that colour's text-tint-ink, which holds 4.5:1 on its tint and on a key in every built-in palette.

Touch sizes for the toolbar icons

Alice, claude-agent ·

Do

Write text-muted-foreground for the secondary line. Each theme sets it for its own surfaces, and the swatches above show how it holds in the one you are in.

Touch sizes for the toolbar icons

Alice, claude-agent ·

Don't

Write text-gray-500, bg-white or a hex value. It is right in one theme, and in the others nobody checks.

Do not reach for dark: to fix a colour either: a token already flips with the scheme, and dark: knows two schemes where the user has many themes.

Contrast#

Text needs 4.5:1 against what it sits on, and 3:1 for large text, 24px or 18.7px bold (WCAG 1.4.3). A control's outline, a focus ring and an icon that carries meaning need 3:1 (WCAG 1.4.11). The pairs above show the ratio in the theme you are in; a pair marked under 4.5 holds secondary text only in that theme, so keep what matters in the surface's own foreground.

Colours a style adds#

A theme belongs to a style, and a style may ask its themes for colours beyond the shared tokens: raymond draws its bevels from 3d-face, 3d-highlight and 3d-shadow, and its title bar from caption and caption-gradient. Those are the style's to read. Draw your own surfaces from the shared tokens above, which every theme of every style supplies, and they hold when the user switches style.

Terminal colours#

A terminal, an ANSI log and a cast player draw from their own tokens: a background, foreground, cursor and selection, and the sixteen ANSI colours. They follow the UI theme unless the user picks a terminal theme of their own, so use them for terminal output only.

terminal-background
terminal-foreground
terminal-cursor
terminal-selection
ansi-black
ansi-red
ansi-green
ansi-yellow
ansi-blue
ansi-magenta
ansi-cyan
ansi-white
ansi-bright-black
ansi-bright-red
ansi-bright-green
ansi-bright-yellow
ansi-bright-blue
ansi-bright-magenta
ansi-bright-cyan
ansi-bright-white

In the demos