Skip to content

Design Tokens

In Figma, when you define a color style called brand/primary and apply it to thirty elements, you can change that color once and all thirty elements update. That is the power of a single source of truth. CSS custom properties — also called design tokens or CSS variables — give you the exact same superpower in code.

Figma conceptCSS equivalent
Color Style brand/primary--color-primary: #7C3AED;
Color Style text/muted--color-text-muted: #6B7280;
Spacing variable space/4--space-4: 1rem;
Radius variable radius/card--radius-card: 12px;

You define all tokens once at the top of your CSS, on the special :root selector. :root means “the entire document” — so these values are available everywhere.

:root {
--color-primary: #7C3AED;
--color-text: #111827;
--color-text-muted: #6B7280;
--color-surface: #FFFFFF;
--space-2: 0.5rem;
--space-4: 1rem;
--space-6: 1.5rem;
--radius-card: 12px;
}

To use a token, write var(--token-name) wherever you would normally write the value:

.card {
background: var(--color-surface);
padding: var(--space-6);
border-radius: var(--radius-card);
}

When your brand color changes from purple to teal, you change one line--color-primary — and every button, link, and highlight on every page updates automatically. Without tokens, you would need to find and replace every hardcoded #7C3AED in every CSS file.

This is exactly why design systems exist: define decisions once, enforce them everywhere.

The card below is built entirely from tokens. Try changing --color-primary in the CSS panel — notice how the button and the tag both update at once.

Where do you typically define CSS custom properties (tokens)?
How do you use a CSS custom property named --color-brand?
What is the main benefit of using design tokens?