Design system · [Product] · version [2.4] · owned by [team] · last reviewed [Date] · [#design-system]
How to use this
Read the section you need and stop. Nobody reads this document from the top: people arrive at it from a search box or from a link in a review comment, in the middle, so every section below is written to make sense on its own.
It is the source of truth. Where this and [Figma] disagree, this wins and the [Figma] library is corrected the same day. Where this and the code disagree, the code has a bug — open one, and put a link to the section in it.
What the system owns, and what you own
Most of the friction around a design system is not disagreement about a colour. It is two teams who each thought the other one was going to decide.
The system owns
- The tokens below, and the right to change themChanged by proposal, never by a pull request in one app
- Every component in this document, on every platformOne implementation, one set of props, one set of states
- The accessibility of those componentsA system component failing [AA] is our bug, not yours
- The [Figma] library, kept in step with the codePublished together; a mismatch is a same-day fix
- One [30]-minute triage a week[Thursday], no agenda needed, anyone may bring anything
Your product owns
- Layout and page compositionUse the space scale; ask and we will document a pattern
- Anything only one product needsKeep it local — and bring it back when a second team asks
- Copy, tone and the wording of errors[Content] owns the words; we own where they sit
- Feature flags, data fetching and stateNothing in the system touches your data layer, ever
- Marketing pages and emailA separate system on purpose; the constraints are not ours
Foundations
Colour
Seven tokens. The fourth column is the one that matters: a token is misused far more often than it is unknown, and "never" is the shortest way to say what a review should catch.
Token | Value | Use it for | Never |
|---|---|---|---|
--color-accent | #2563EB | The one primary action on a screen | Two primary actions on one screen |
--color-accent-strong | #1D4ED8 | Hover and pressed on the accent | As a fill anywhere else |
--color-surface | #FFFFFF | Cards, panels, menus, sheets | The page background |
--color-canvas | #F8FAFC | The page behind the surfaces | Inside a card |
--color-text | #0F172A | Body copy and headings | On top of the accent fill |
--color-text-muted | #64748B | Labels, captions, help text | Anything a user must read to act |
--color-danger | #DC2626 | Destructive actions and errors | Warnings, cautions, anything reversible |
Type
Seven steps, and nothing between them. Size and line height are one decision, not two.
Token | Size / line height | Weight | Use it for |
|---|---|---|---|
--text-display | 40 / 44 | 700 | One per page, at the very top |
--text-h1 | 30 / 36 | 700 | The page title |
--text-h2 | 24 / 32 | 600 | Section headings |
--text-h3 | 18 / 26 | 600 | Subsections and card titles |
--text-body | 15 / 24 | 400 | Everything a user actually reads |
--text-small | 13 / 20 | 400 | Labels, captions, table cells |
--text-mono | 13 / 20 | 400 | Code, ids, anything meant to be copied |
Space and radius
Paste this and use nothing else. Every gap, pad and margin in every component is one of these values.
:root {
/* Space. Seven steps on a 4px base — see the note below for why 4 and not 8. */
--space-1: 4px;
--space-2: 8px;
--space-3: 12px;
--space-4: 16px;
--space-6: 24px;
--space-8: 32px;
--space-12: 48px;
/* Radius. Three, and the last one is for pills and avatars only. */
--radius-sm: 4px;
--radius-md: 8px;
--radius-full: 999px;
}Why the scale is [4px] and not [8px]
Because [8px] is too coarse for the inside of a control, and every time we tried it we ended up writing [12px] anyway. A [4px] base gives seven steps, which is enough to be expressive and few enough that a reviewer can see a wrong one without measuring it.
The rule that makes the scale work is that nothing is allowed between the steps. If a layout needs [10px] then either the layout is wrong or the scale is, and the second one is a conversation in [#design-system] rather than a number typed into a component.
Components
States
Two components down the side, three states across. Read a row to build one component, read a column to check that two components behave the same way in the same state — which is the thing that is actually hard to keep true.
Two components, three states, one set of rules
Button — rest
- Fill --color-accent
- Radius --radius-md
- Pad --space-2 --space-4
Button — hover, focus
- Fill --color-accent-strong
- Ring 2px, offset 2px
- Transition 150ms
Button — disabled
- Opacity 0.5
- No ring and no hover
- Cursor not-allowed
TextField — rest
- Border 1px --color-text-muted
- Radius --radius-sm
- Label above, never inside
TextField — hover, focus
- Border --color-accent
- Ring 2px, offset 0
- Placeholder still visible
TextField — disabled
- Fill --color-canvas
- Value still selectable
- Label keeps full contrast
Button
Typed against the tokens above. There is no `color` or `padding` prop, and there will not be one.
// One primary action per screen. Everything else is secondary or ghost.
<Button>Save changes</Button>
<Button variant="secondary">Cancel</Button>
<Button variant="ghost" size="sm">Learn more</Button>
// Destructive actions confirm somewhere else. The button does not confirm for you.
<Button variant="danger" onClick={() => confirmThenDelete(id)}>
Delete [project]
</Button>
// Loading keeps the button's width, so nothing around it moves.
<Button loading>Save changes</Button>TextField
The label is a prop rather than a sibling, which is how the system guarantees there is no unlabelled input in the product.
<TextField label="Work email" name="email" type="email" />
// An error says what to do, not what went wrong.
<TextField
label="Password"
name="password"
type="password"
error="Use at least [8] characters, including one number"
/>
// Help text is permanent; an error replaces it and is announced once.
<TextField
label="Workspace URL"
name="slug"
help="Letters, numbers and dashes"
/>The accessibility bar
Three lists, consulted one at a time while you build. Nothing here is aspirational — a component that fails any of it does not go in the system.
Colour and contrast
Checked with [tool] before a token pairing goes in a component, not after:
- Body text is --color-text on --color-surface or --color-canvas, which is [AAA] on both.
- --color-text-muted is [AA] on those two and fails on anything darker. Never on a fill.
- Nothing is distinguished by colour alone — an error carries an icon and a sentence.
- The focus ring needs [3:1] against whatever is behind it, which is why it has an offset.
Keyboard
Every one of these is testable in under a minute, with the mouse pushed away:
- Everything actionable is reachable with Tab, in the order it appears on screen.
- The focus ring is never removed. If it looks wrong, the padding is wrong.
- Escape closes the topmost layer only, and returns focus to whatever opened it.
- No keyboard trap: if focus can get in, Tab and Escape can both get it out.
Screen readers
Tested on [VoiceOver] with [Safari] and [NVDA] with [Firefox] before it ships:
- Every input has a real label. `aria-label` is for icon-only buttons and nothing else.
- A live region announces the result of an action once — never on every keystroke.
- Decorative icons are aria-hidden; a meaningful one has text beside it.
- Headings go down one level at a time, because that is how the page is navigated.
Getting something into the system
The loop is the part worth drawing. Using the closest existing component does not end the conversation — the gap goes to the same [Thursday] triage, which is the half of this rule everybody forgets and the reason the system knows what it is missing.
- 1
You need something the system does not have
Then step 2
- 2
Close match?
Yes: step 3. No: step 4
- 3
Use it, and open an issue for the gap
Then step 5
- 4
Post the use case in [#design-system]
Then step 5
- 5
Accepted?
Yes: step 6. No: step 7
- 6
We build it with you and ship it documented
- 7
Keep it local, and say so in the code
Definition of done for a new component
Ticked once per component, by whoever is reviewing it rather than whoever built it. Nothing goes in the [Figma] library or the package until all eight are true.
- It uses only the tokens above — no literal colour, size, spacing or radius anywhere in it.
- Every state in the matrix is implemented and visible in [Storybook].
- Keyboard: reachable, operable, and it hands focus back when it closes.
- Contrast checked at [AA] for text and [3:1] for the focus ring and every border.
- It works from [320px] to [1920px] with no horizontal scrollbar at any width.
- Props are named the same as the equivalent props on Button and TextField.
- A section in this document: one example of the common case, one of the hard one.
- The [Figma] component is published in the same version, with matching layer names.
What is going away
Nothing is removed without a version and a date in this table first, and nothing appears in it without a replacement that already exists.
Going away | Use instead | Removed in |
|---|---|---|
Panel | Card, which is the same thing built from tokens | [v3.0], [March] |
Alert | Callout, with a tone | [v3.0], [March] |
--brand-blue | --color-accent | [v2.6], already unused in [3] of [5] apps |
IconButton | Button, with variant ghost and no children | [v3.1], [June] |