Design Tokens
The variable layer every component reads from: how tokens are named and layered, how to consume them, and how to change one without breaking the system.
The variable layer every component reads from: how tokens are named and layered, how to consume them, and how to change one without breaking the system.
Ask about your design system
Ask about components, tokens, and patterns — or request help building something new.
AI can make mistakes. Always verify important information.
What tokens are for
A token is a named design decision. Components reference the name, never the raw value.
That indirection is the point. Change the token and every component that uses it changes with it. Hardcode the value and the change becomes a search-and-replace across the codebase, which is where drift starts.
Layers
Tokens are worth splitting into layers so that intent survives a redesign:
Components consume the semantic layer. Reaching past it into primitives couples a component to a value rather than to a decision.
This system exposes its tokens as CSS custom properties on
:root, with semantic names such as--ink,--muted,--surface,--borderand--accentfor colour,--font-displayand--font-bodyfor type, and--radius-cardand--radius-pillfor shape.Naming
--accentsurvives a rebrand,--bluedoes not.--accent-hoverreads the same way as--accent-contrast.surfaceorbackgroundand never mix them.--gray-400invites a--gray-450.Using tokens
1.card { 2 background: var(--surface); 3 color: var(--ink); 4 border: 1px solid var(--border); 5 border-radius: var(--radius-card); 6} 7 8.card__meta { 9 color: var(--muted); 10}Rules:
var()a fallback only where the token may genuinely be absent. A fallback everywhere hides a missing token instead of surfacing it.1[data-theme='dark'] { 2 --ink: #f5f5f5; 3 --surface: #161616; 4 --border: #2c2c2c; 5}Changing a token
A token change is a global change. Treat it as one.
Adding a token
Add one when the same value appears in three or more places and represents a real decision. Before adding, check that an existing token does not already cover it. Two tokens with the same value and overlapping meaning are worse than none, since neither can be changed with confidence.
Anti-patterns