Token contract
YAML in tokens/ is the source. npm run build writes CSS, themes.json, a DTCG exchange file, contract.json, and tokens.d.ts. Do not edit dist/. contract.json includes each public token’s resolved value, so a consumer can see the decided length or color without inventing one.
DTCG is an output for other tools. It is not the file people edit. Supernova and Tokens Studio are not part of this pipeline.
| File | What it holds |
|---|---|
tokens/primer.yaml |
Name, prefix, themes, file order, symbols, guarantees |
tokens/color.yaml |
Palette ramps and color roles |
tokens/space.yaml |
Space and radius |
tokens/type.yaml |
Font families, sizes, weights, line height |
tokens/motion.yaml |
Duration and easing |
tokens/layout.yaml |
Page measurements |
tokens/control.yaml |
Web control metrics for the screen specimens. Values point at existing tokens. |
tokens/desktop.yaml |
Opt-in native desktop surfaces, comfortable density, open-canvas composition roles, shape, and elevation |
tokens/terminal.yaml |
Terminal cell counts |
tokens/deprecated.yaml |
Old public names, removed in 1.0.0 |
tokens/accents.yaml |
Alternate accents. Orange is the default; brown is an explicit alternate |
tokens/pipelines.yaml |
Which files the build writes |
Quote hex colors. In YAML, # starts a comment.
A token’s public name is its identity. Scales step outward from base: small-300, small-200, small-100, base, large-100, and so on. Color roles use base, subdued, and strong, plus tone names such as critical and success.
color.text is both a group and a deprecated alias of color.text.base. A deprecated name stays until 1.0.0 and points at its replacement with replacedBy.
The palette is public but deprecated. Product CSS uses color roles. color.chart.series-1 follows the accent. series-2 and series-3 are the other chart series.
Themes and accents
Section titled “Themes and accents”Dark is the default. Light overrides it with [data-primer-theme="light"]. [data-primer-theme="system"] follows the operating system through a media query; it chooses one of the same two themes. One accent is active at a time. Orange is the default; brown is an explicit alternate. Another accent is [data-primer-accent="green"] and the other names in tokens/accents.yaml.
Desktop profiles compose independently: data-primer-density="comfortable" remaps sizing, while data-primer-layout="open-canvas" remaps surfaces, selection, and composition measures on .primer-desktop. The generated CSS validates every remapped token’s type. The underlying desktop.density.comfortable.* and desktop.layout.open-canvas.* roles are also available directly. See desktop foundations for adoption and application ownership.
color is #rrggbb. space, radius, fontSize, and dimension are px or rem. duration is ms or s. letterSpacing may also be a percent. lineHeight is a number. fontFamily and fontWeight are families and weights. easing is four numbers. cells is a positive integer. A value that matches another token’s path is a reference. A path that matches nothing fails the build.
shadow is a structured value with color (#rrggbb or #rrggbbaa), dimensions offsetX, offsetY, blur, and spread, and optional boolean inset. The authoring format supports one shadow per token, or a whole-token alias. CSS and app JSON expose the usable box-shadow string; the DTCG output preserves the structured shadow value. Translucency is allowed inside shadows; ordinary color roles remain opaque for contrast and terminal rendering.
Guarantees
Section titled “Guarantees”tokens/primer.yaml lists contrast pairs and scales that must ascend. The build fails with the pair and the ratio when a guarantee does not hold. The check runs for every accent and both themes.
Public outputs
Section titled “Public outputs”dist/contract.json lists public names, CSS variables, JSON keys, types, deprecations, classes, terminal roles, accents, guarantees, and the component specs from specs/. It has no values. dist/tokens.css is the web variables. dist/themes.json is the resolved values. Deprecated CSS names that match their replacement are written once.
Checks
Section titled “Checks”npm run tokens:check fails on unknown --primer-* variables, internal tokens used from app code, and theme variables defined outside dist/tokens.css. Deprecated names warn. Tailwind palette classes, hex colors, and raw pixel sizes are reported and do not fail the check.
npm run tokens:migrate -- --write rewrites deprecated variables, JSON keys, and classes. Without --write it only prints the files it would change.
See token procedures for versioning and migrating to 1.0 for the alias removal.