Skip to content

Theming

Rebrand the system for a client by editing app/globals.css alone, choosing the layer that gives the outcome you want.

The whole Silkware theme lives in one file, app/globals.css. A client brand is produced by editing that file and nothing else: no component changes, no class changes, no wrappers. This page shows which layer to edit for which outcome, how to add a token, a worked example that was run against the real contrast checker, and the theme editor that writes the file for you.

Silkware
Brescia site, purchasing

Units per delivery.

Draft Waiting on Luca
Client
Brescia site, purchasing

Units per delivery.

Draft Waiting on Luca

The panel on the right is the same card with five token values replaced on its wrapper: the radius, the primary colour, the focus ring, the brand colour and the error colour. Nothing else differs. That is how far a token reaches.

The layers, and which one to edit

globals.css has three layers. Colour lists every token in them.

You wantEditWhereExample
A different brand colour everywhereLayer 1, brand primitives:root--crimson, --crimson-pale, --crimson-deep, --crimson-light
New greys and a new blackLayer 1:root--ink, --fog, --seal
The primary button in the brand colour, not inkLayer 2, semantic tokens:root for light, .dark for dark--primary: var(--crimson-deep)
Errors in a real redLayer 2both modes--destructive
Different status coloursLayer 1 for the hue, layer 2 for the roleboth modes--pine, --amber, --cobalt and their -light steps, read by --success, --warning, --info
Control bordersLayer 2both modes--input-edge for the border of a field, --input for its fill
Code coloursLayer 2both modes--syntax-token-keyword, --syntax-token-string and the rest of the --syntax- set
The size of a touch target:root--touch-target, used inside a touch-controls scope only
A different typefaceLayer 1, :root--typeface-mona, --font-text, --font-title
Softer or squarer corners:root--radius
Thicker or thinner icons:root--icon-stroke, --arrow-stroke
Line heights and tracking of the type scale:root--leading-xs to --leading-6xl, --tracking-xl to --tracking-6xl
Heading, control and text weights:root--weight-heading, --weight-control, --weight-text
The editorial steps of a landing page:root--step-display, --step-statement, --step-lead and their --leading-* and --tracking-*
The reading rhythm of rendered text:root--typeset-docs-size, --typeset-docs-leading, --typeset-docs-flow, and the --typeset-chat- and --typeset-compact- pairs
Looser or tighter layout:root--pad-x, --gutter, --section-pad, --stack-gap
Shadows:root--elevation-panel-light, --elevation-panel-dark
A new utilityLayer 3@theme inline--color-highlight: var(--highlight)

Start from the top. A change to layer 1 moves every semantic token that points at it. A change to layer 2 moves one role. Layer 3 maps names to utilities, and you edit it only to add a name.

The sizes of the standard steps are Tailwind's own and live in @theme inline; a rebrand changes their line heights and tracking, not their names. The Typeset presets read their values from :root as well, and the theme editor lists them under Rendered text. See Typography and Typeset.

Two rules hold throughout. Keep both modes: every semantic colour needs a light value and a dark value. And do not edit a file in components/ui: if an outcome needs one, it cannot be reached by a theme and is a recorded gap (see Principles).

A worked example

A fictional client, Ternmoor Engineering, wants a deep teal in place of crimson, softer corners and a humanist sans. Every step below was done in the theme editor, starting from the Silkware theme, in this order. After each one the editor's header reports the number of changes and the contrast result, and those numbers are quoted here. The outcome is close to the Ternmoor Engineering preset but not the same file: the editor derives the tints from the accent, and the preset was set by hand.

  1. Choose the accent

    On the Brand step, under Accent, choose Teal (#0f766e). The editor writes the four crimson primitives, which keep their names because layer 2 points at them. The deeper and lighter tints are derived so they hold contrast.

    -  --crimson: #d81f5c;-  --crimson-pale: #f9d7e2;-  --crimson-deep: #b8184e;-  --crimson-light: #ff99b4;+  --crimson: #0f766e;+  --crimson-pale: #c9e0de;+  --crimson-deep: #0f736c;+  --crimson-light: #75b0ac;

    The header now reads 4 changes and 2 contrast failures, both on destructive buttons. --destructive is defined as var(--crimson-deep) in light and var(--crimson-light) in dark, so errors are now teal as well. Brand and error were one colour in Silkware.

  2. Split the error colour

    On the Tokens step, find --destructive and give it a red of its own in each mode. With Light values selected, set it to #b42318; with Dark values selected, to #fda29b. The dark value must be light enough for small text on ink.

    -  --destructive: var(--crimson-deep);+  --destructive: #b42318;
    -  --destructive: var(--crimson-light);+  --destructive: #fda29b;

    The first is in the light block, the second in the .dark block. The header reads 6 changes and contrast passes.

  3. Choose what the primary button is

    Silkware's primary button is ink. Under Primary actions on the Brand step, choose Accent. The editor points the primary and the sidebar's primary at the deep teal in light and at the light teal in dark.

    The header now reads 10 changes and 1 contrast failure: the hover state of the primary button, teal at 80% under white text, is 3.82:1. Open the Contrast step and press the one-press fix, Set primary to #0e625c. The pair passes at 4.5:1 and the header reads contrast passes.

    -  --primary: var(--ink);+  --primary: #0e625c;-  --sidebar-primary: var(--ink);+  --sidebar-primary: var(--crimson-deep);

    In dark mode --primary becomes var(--crimson-light).

  4. Tint the greys

    Under Neutrals, choose From the accent. Eleven grey primitives, from --ink to --smoke, move a little towards teal, so surfaces, borders and notes sit quietly beside the accent. Ink changes from #0a0a0a to #040c0b. Contrast still passes at 21 changes.

  5. Set the typeface and the corners

    Under Typeface, choose Humanist sans for running text and again for headings. Under Corners, choose Soft.

    -  --font-text: var(--typeface-mona);-  --font-title: var(--typeface-mona);+  --font-text: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;+  --font-title: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;-  --radius: 0.5rem;+  --radius: 0.875rem;

    --radius moves every step of the scale together, because each step is a fraction of it. For a web font that the visitor does not have installed, add an @font-face rule beside the two that load Mona Sans and Noto Sans SC, and put the file under public/fonts/.

  6. Look at it, then check it

    Use the scenes above the preview (Dashboard, Form, Table, Agent, Type), switch between Light, Dark and Both, and between Desktop and Phone. Press Show original to compare with the shipped theme: your edits are kept. The Contrast step reads "All 229 checks pass", the same checks as pnpm check:contrast, which reads app/globals.css, resolves every var() and exits with an error on any pair under 4.5:1 for text or 3:1 for rings, edges and marks.

    The finished theme has 24 changes. The Hand over step lists each one, and the file it exports is the complete globals.css.

When a change fails

A value that looks fine can still fail. In the editor, set the light --muted-foreground to var(--ash), a lighter grey, and the header reports 1 change and 7 contrast failures: 2.36:1 for muted text on a secondary surface and 2.57:1 for notes, card descriptions and menu shortcuts, against 4.5:1 needed. The Contrast step names each pair and offers the nearest value that passes, #6e6e71. Take it, or choose a darker grey yourself. Fix the value, not the check.

On a dark ground, a dark brand colour can pass as a square and fail as text. In the worked example the teal on the dark ink is 3.61:1, which passes the 3:1 for marks, but teal text on ink would not pass 4.5:1. Where the brand colour is used as text in dark mode, point --brand at a lighter step in the .dark block, as the Veltrane Instruments preset does.

Add a token

When a client needs a role the system does not have, such as a highlight for notes, add it in three places, in this order.

:root,.light,[data-theme="light"] {  --highlight: #fef3c7;  --highlight-foreground: var(--ink);}
.dark,[data-theme="dark"] {  --highlight: #422006;  --highlight-foreground: var(--white);}
@theme inline {  --color-highlight: var(--highlight);  --color-highlight-foreground: var(--highlight-foreground);}

With the three blocks in place, bg-highlight and text-highlight-foreground exist as utilities: Tailwind generated .bg-highlight { background-color: var(--highlight); } from the edited file, and the unedited file generates no such class. Without the @theme inline lines, the variable exists and no utility does.

Declare the pair in both modes, name a foreground for every fill, and add the pair to contrastPairs in lib/theme/tokens.ts if you want the checker to cover it. That file is shared with the theme editor and is outside a rebrand, so ask the maintainers to add it.

The theme editor

You do not have to edit the file by hand. The theme editor at /themes has four steps beside a large preview, and it exports a complete globals.css.

  1. Brand. Start from Silkware, Ternmoor Engineering or Veltrane Instruments, or import a globals.css. Then make the brand decisions: the accent (the tints are derived), whether primary actions are ink or the accent, the neutrals, the typeface for text and for headings, the heading weight (500, 600 or 700), the heading tracking (tight, or none for a serif or a wide face) and the corners. Each decision lists the tokens it writes. The Tokens step lists the line heights, tracking and weights under Type scale and Typefaces and weights.
  2. Tokens. Every declaration in the file, found by name, label or value, for light or dark values, filtered to All, Changed or Failing. Edit a value, follow a var() to the token it reads, reset one token to the file value, or press Show where to see where it lands in the preview.
  3. Contrast. Every pair the system checks, 229 in all, with the failures first. Each failure names the pair, its ratio and the minimum, and offers the nearest value that passes as a one-press fix, or opens the token for you to edit.
  4. Hand over. The list of changes, the contrast result, and the file: Download globals.css or Copy file. A switch applies your theme to the whole documentation site in this browser.

The preview has five scenes (Dashboard, Form, Table, Agent and Type), shows light, dark or both, at desktop or phone width. Show original compares with the shipped values without losing your edits. Undo and redo step through every change, also with Control or Command and Z. On a narrow screen an Edit and Preview switch replaces the side-by-side layout. Your edits are kept in this browser, so you can leave and return.

The export is the shipped file with only the edited declarations replaced: the line count and the order are the same, so it diffs cleanly. With no edits, the export is the shipped file byte for byte. pnpm check:theme verifies this, together with the round trip through import and the contrast of all three presets.

  • Colour for what every token does.
  • Dark mode for how the two modes are switched.