Most design systems fail not because the colors look bad. They fail because every team picks its own hex code. The designer chooses slate-800 in Figma. The frontend developer writes #1e293b in a component. Six months later, someone else picks #0f172a for the same element. Now you have three near-identical dark grays, no documentation, and a refactor that touches fifty files.
Design tokens solve this by moving style decisions out of components and into a shared layer. A token is a named value that represents a design decision. Instead of hardcoding colors, spacing, and typography inside components, you reference a token. When the brand color changes, you update the token in one place and every component inherits the change.
Here is how to implement this in 2026, from Figma to CSS variables to Tailwind config.
What Design Tokens Actually Are
A token is not a variable. A variable is a storage bucket. A token is a named design decision with a clear purpose.
Think of it this way:
- Color value: #1e293b
- CSS variable: --color-900
- Design token: color.surface.inverse
The first two tell you how to store the value. The third tells you what the value is for. That distinction matters. When a new developer joins the team, they do not need to guess whether --color-900 is for text, backgrounds, or borders. They see color.surface.inverse and know exactly where it belongs.
Tokens usually live in three layers:
Primitive tokens store raw values without context.
- color.slate-900 = #0f172a
- spacing.4 = 1rem
- fontFamily.sans = Inter, system-ui, sans-serif
Semantic tokens assign meaning to primitives.
- color.background.primary = color.slate-50
- color.text.primary = color.slate-900
- spacing.section = spacing.16
Component tokens bind semantics to specific UI parts.
- button.primary.background = color.background.primary
- button.primary.text = color.text.inverse
- card.border.radius = radius.md
This separation lets you change primitives without touching components, and swap themes without rewriting semantics.
Naming Tokens So Developers Actually Use Them
Bad token names look like this:
- color-red-500
- bg-dark
- text-main
- spacing-big
They describe appearance, not intent. When the brand color changes from red to orange, the name color-red-500 becomes a lie. Developers stop trusting the system and start hardcoding values again.
Good token names describe purpose and hierarchy:
- color.brand.primary
- color.brand.primaryHover
- color.surface.elevated
- spacing.layout.section
- spacing.control.tight
- radius.control.small
- radius.control.medium
Use dot notation. Group by category, then by intent. Avoid color names in token identifiers unless the token is specifically a primitive swatch.
Mapping Figma Tokens to CSS Variables
If your design team works in Figma, they likely already use local variables or styles. The mistake most teams make is copying hex codes by hand. That introduces drift the moment a designer updates a color in Figma.
Instead, export Figma variables as JSON using the Figma REST API or a community plugin. Then transform that JSON into CSS variables during your build step.
A primitive token export might look like this:
{
"color": {
"slate-50": "#f8fafc",
"slate-900": "#0f172a",
"indigo-600": "#4f46e5"
},
"spacing": {
"1": "0.25rem",
"4": "1rem",
"16": "4rem"
}
}
Your build script converts it to CSS variables in a base stylesheet:
:root {
--color-slate-50: #f8fafc;
--color-slate-900: #0f172a;
--color-indigo-600: #4f46e5;
--spacing-1: 0.25rem;
--spacing-4: 1rem;
--spacing-16: 4rem;
}
Then semantic tokens reference primitives:
:root {
--color-background-primary: var(--color-slate-50);
--color-text-primary: var(--color-slate-900);
--color-brand-primary: var(--color-indigo-600);
--spacing-section: var(--spacing-16);
--spacing-control-tight: var(--spacing-1);
}
Components consume semantic tokens, never primitives directly:
.button-primary {
background-color: var(--color-brand-primary);
color: var(--color-text-inverse);
padding: var(--spacing-control-tight) var(--spacing-4);
}
This creates a single source of truth. Change --color-indigo-600 once, and every button, link, and badge updates.
Converting CSS Variables to Tailwind Config
Tailwind does not read CSS variables automatically. You must map them into tailwind.config.js so your utility classes can use them.
Here is a practical mapping for the tokens above:
// tailwind.config.js
import { fontFamily } from 'tailwindcss/defaultTheme'
export default {
darkMode: 'class',
theme: {
extend: {
colors: {
slate: {
50: 'var(--color-slate-50)',
900: 'var(--color-slate-900)',
},
indigo: {
600: 'var(--color-indigo-600)',
},
background: {
primary: 'var(--color-background-primary)',
},
text: {
primary: 'var(--color-text-primary)',
inverse: 'var(--color-text-inverse)',
},
brand: {
primary: 'var(--color-brand-primary)',
},
},
spacing: {
1: 'var(--spacing-1)',
4: 'var(--spacing-4)',
16: 'var(--spacing-section)',
},
borderRadius: {
sm: 'var(--radius-control-small)',
md: 'var(--radius-control-medium)',
},
fontFamily: {
sans: ['Inter', ...fontFamily.sans],
},
},
},
}
Notice the pattern. Each Tailwind key points to a CSS variable. This gives you two benefits:
- You write utility classes like bg-brand-primary and text-text-primary in your HTML.
- If the design system changes, you update the CSS variable, not every HTML file.
Do not hardcode hex values inside tailwind.config.js. That defeats the purpose of tokens. The config file should only contain references to CSS variables or standard Tailwind defaults.
Dark Mode Token Mapping
Dark mode is where token systems prove their value. You do not duplicate components. You swap the variable values.
:root {
--color-background-primary: var(--color-slate-50);
--color-text-primary: var(--color-slate-900);
--color-brand-primary: var(--color-indigo-600);
}
.dark {
--color-background-primary: var(--color-slate-950);
--color-text-primary: var(--color-slate-50);
--color-brand-primary: var(--color-indigo-400);
}
Your components remain unchanged. A button that uses var(--color-background-primary) automatically adapts when the .dark class is applied to the html element.
Tailwind handles this with dark mode variants:
<button class="bg-brand-primary dark:bg-brand-primary text-text-inverse dark:text-text-inverse">
Save
</button>
Or simpler, if your semantic names already account for darkness:
<button class="bg-background-primary dark:bg-background-primary text-text-primary dark:text-text-primary">
Save
</button>
The first approach is more explicit. The second is more maintainable at scale. Choose one and apply it consistently.
Real Example: A Button Component
Here is a button built entirely from tokens. No hardcoded colors, no arbitrary values.
HTML:
<button class="button button-primary">
Save changes
</button>
CSS:
.button {
display: inline-flex;
align-items: center;
justify-content: center;
padding: var(--spacing-control-tight) var(--spacing-control-medium);
font-family: var(--font-sans);
font-size: var(--text-size-base);
font-weight: 500;
line-height: 1.5;
border-radius: var(--radius-control-medium);
border: none;
cursor: pointer;
transition: background-color 0.2s ease, opacity 0.2s ease;
}
.button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.button-primary {
background-color: var(--color-brand-primary);
color: var(--color-text-inverse);
}
.button-primary:hover:not(:disabled) {
background-color: var(--color-brand-primaryHover);
}
.button-secondary {
background-color: var(--color-background-secondary);
color: var(--color-text-primary);
border: 1px solid var(--color-border-default);
}
.button-secondary:hover:not(:disabled) {
background-color: var(--color-background-secondaryHover);
}
Notice there are no hex codes. No px-4 or py-2 utility classes inline on the button itself. The component owns its design decisions through tokens. If marketing wants a larger primary button next quarter, you update --spacing-control-medium once.
Common Mistakes That Break Token Systems
Mistake 1: Exposing primitives to components
Never let a component use --color-indigo-600 directly. If the brand changes from indigo to rose, every component breaks. Components consume semantic tokens only.
Mistake 2: Naming tokens after values
A token named --color-red is useless when the brand changes to blue. Name it --color-brand-error or --color-state-critical instead.
Mistake 3: Creating one token per component
Do not create --button-primary-background and --card-primary-background as separate tokens if they share the same value. Use one semantic token, color.background.primary, and reference it in both places. Duplicated tokens drift apart over time.
Mistake 4: Forgetting dark mode at the start
Add dark mode variables from day one, even if you do not ship dark mode yet. Retrofitting a token system is harder than building it with dark mode in mind.
What This Means for Your Team
Design tokens are not a Figma feature. They are a contract between design and frontend. When the contract lives in code as CSS variables and Tailwind references, everyone works from the same source. Designers stop asking why the button color is off by one shade. Developers stop asking which hex code to use. The system becomes the single source of truth.
Start with colors and spacing. Add typography and border radius next. Let components consume semantic tokens, not primitives. Your codebase will be easier to maintain, and your product will look consistent across every page.