Global tokens
Raw scales such as color, spacing, radius and font sizes.
Design tokens are named design decisions. They turn repeated colors, spacing, fonts and motion values into a system.
:root {
--color-action: #8cffc1;
--radius-card: 28px;
}
Architecture mental model
A token is a named value that represents a design decision: a brand color, text color, spacing step, radius, shadow, font size or motion duration.
Tokens become powerful when they describe meaning instead of only raw values. --color-danger is easier to maintain than remembering every red hex value.
CSS custom properties are a practical way to implement tokens directly in the browser.
Raw scales such as color, spacing, radius and font sizes.
Meaningful aliases such as text-muted or surface-raised.
Local values for a specific component when needed.
Values that can change between light, dark or brand themes.
Visual model
The base design scale stores raw values.
Meaning maps the raw value to a role.
A component can consume the semantic value.
Themes swap values without rewriting components.
Good CSS versus fragile CSS
:root {
--green-500: #8cffc1;
--color-action: var(--green-500);
--button-bg: var(--color-action);
}
.button { background: var(--button-bg); }
.button { background: #8cffc1; }
.badge { color: #8cffc1; }
.link { border-color: #8cffc1; }
Rules of thumb
If a value repeats and has meaning, give it a name.
Components should use --color-action more often than --green-500.
Do not create 47 almost-identical spacing values.
Custom property fallbacks help when values are optional or theme-driven.
A one-off art direction detail may not need a global token.
Future developers should know when to use each token.
Production thinking
Tokens let a design system move as one piece. A redesign becomes a set of value changes instead of a scavenger hunt.
Contrast-sensitive tokens should be checked as pairs, such as text on surface or action text on action background.
Token naming is architecture. Once templates and components depend on names, changes should be deliberate.
Tokens do not affect ranking directly, but consistent visual systems improve usability and trust.
Live code lab
The preview runs in an isolated iframe. Links and forms stay inside the practice area, so you can experiment without leaving the lesson.
Mini assignment
Practice assignment
Try it yourself
Self-check
Answer these questions before moving on. If you cannot find, name or move a rule safely, the architecture still needs work.
Senior audit upgrade
A token system becomes much easier to maintain when raw values, meanings and component roles are not mixed together.
--color-blue-500 or --space-4 stores a raw scale value.
--color-action or --color-danger carries product meaning.
--button-bg or --card-padding tunes a specific component role.