Design tokens
A token is a named value, such as --surface-1 or --brand-ink, that holds a color, a shadow or a curve for both themes. Write the name in code and the value follows the theme.
The token files
The tokens come in three files. Link werklist-tokens.css in a web page. Read werklist-tokens.json in a design tool or a script. Use werklist-tokens.print.css for anything printed: it holds the light values only, without glass or shadows.
How the theme switches
In the CSS file, dark values sit on :root and light values on html[data-theme="light"]. Write data-theme on the root element in both themes, because without it the file gives the dark values. WerkOS always writes it and opens in light.
A token that does not change between themes, such as --brand-true, is declared once, on :root. In the JSON file, $value holds the light value, and the com.werklist.mode extension holds the dark value as well.
/* werklist-tokens.css */
:root {
--surface-1: #191c2c;
--text: #ffffff;
}
html[data-theme="light"] {
--surface-1: #ffffff;
--text: #0d0d12;
}
/* your stylesheet */
.panel {
background: var(--surface-1);
color: var(--text);
}--surface-1--textNames in code
The tokens a screen is built from are named for their job, not their look: --surface-control, not --light-grey.
Write the token through var(), as in background: var(--surface-1), and the value follows the theme.
- Page
- background
- var(--bg)
- Panel
- background
- var(--surface-1)
- Band
- background
- var(--surface-2)
- Nested box
- background
- var(--surface-strong)
- Control fill
- background
- var(--surface-control)
- Scrim
- background
- var(--overlay)
- Body text
- color
- var(--text)
- Supporting text
- color
- var(--text-muted)
- Labels
- color
- var(--text-label)
- Blue text
- color
- var(--brand-ink)
- Edge of a control
- border-color
- var(--border)
- Row rule
- border-color
- var(--border-rule)
- Marks
- background
- var(--brand-blue)
- Button fill
- background
- var(--brand-true)
- Text on the button fill
- color
- var(--on-brand)
- Status fills
- background
- var(--success), var(--warning), var(--error)
- Status inks
- color
- var(--success-ink), var(--warning-ink), var(--error-ink)
Families
These are the families a screen is built from, and each has its own page with its scale and its rules. The rest of the file holds tokens that belong to one part of the product, such as --chat-bubble-own in chat, and they are used only there.
Color
- Surfaces
- --bg, --surface-1, --surface-2, --surface-strong, --surface-control, --overlay
- Text
- --text, --text-label, --text-muted
- Lines
- --border, --border-rule, --input-border
- Brand
- --brand-true, --brand-blue, --brand-ink, --on-brand
- Status
- --success, --warning, --error, --success-ink, --warning-ink, --error-ink
- Selection
- --nav-fill-active, --track-tint, --seg-selected
Layout
- Spacing
- --space-1 to --space-32
Shape
- Radius
- --radius-sm to --radius-full
Elevation and materials
- Elevation
- --elevation-0 to --elevation-3
- Glass
- --glass-fill, --glass-shadow-card, --glass-shadow-panel, --glass-shadow-raised
- Layers
- --layer-sticky to --layer-toast
Motion
- Duration
- --duration-instant to --duration-slow
- Easing
- --ease-standard, --ease-soft
Typography
- Type
- --type-display to --type-product-caption-small
Accessibility
- Focus
- --focus-ring, --focus-ring-width, --focus-ring-offset
Permitted and not permitted
Permitted
Read colors through their token names.
The value then follows the theme.
Write data-theme on the root element, light included.
Without it the page takes the dark values.
Use the print file for anything on paper.
Not permitted
Copy a value from the JSON file into code.
It keeps one value when the theme changes.
Name a new token for how it looks, such as --light-grey.
The name stops being true in the dark theme.
Edit your copy of a token file.
Take the files as they are published, so every screen reads the same values.