Design Tokens Explained: The Bridge Between Design and Code
Design tokens are the single source of truth for your brand's visual properties. Learn how to implement them in your project for consistent, maintainable styling.
If you've worked on a project where the button color is defined in 47 different places, you understand the problem design tokens solve.
Design tokens are named values that store visual design decisions. Instead of hardcoding #3b82f6 everywhere, you use --color-primary. When the brand evolves, you change one value instead of hunting through thousands of lines of code.
What are design tokens?
Design tokens are the atoms of your design system. They capture decisions like:
- Colors:
primary-500,background,text-muted - Typography:
font-heading,text-lg,line-height-tight - Spacing:
space-4,space-8,padding-card - Effects:
shadow-sm,radius-lg,transition-fast
The key insight: tokens are platform-agnostic. The same token can output CSS variables, Tailwind config, iOS Swift code, or Android XML.
Tokens vs. variables
You might think: "I already use CSS variables. How is this different?"
CSS variables are an implementation. Tokens are the concept.
/* CSS variable - one platform */
:root {
--color-primary: #3b82f6;
}
/* Design token - source of truth */
{
"color": {
"primary": {
"value": "#3b82f6",
"type": "color"
}
}
}From that single token definition, tools can generate:
- CSS:
--color-primary: #3b82f6 - Tailwind:
primary: '#3b82f6' - iOS:
static let primary = Color(hex: "3b82f6") - Figma: A style named "primary"
Token taxonomy
Well-structured tokens have layers:
Primitive tokens (raw values)
{
"blue-500": { "value": "#3b82f6" },
"blue-600": { "value": "#2563eb" },
"gray-50": { "value": "#f9fafb" }
}Semantic tokens (meaning)
{
"color-primary": { "value": "{blue-500}" },
"color-primary-hover": { "value": "{blue-600}" },
"color-background": { "value": "{gray-50}" }
}Component tokens (specific use)
{
"button-background": { "value": "{color-primary}" },
"button-background-hover": { "value": "{color-primary-hover}" }
}This layering means you can swap your entire color palette by changing primitive tokens, without touching component code.
Implementing tokens in your stack
CSS Variables
The most universal approach:
:root {
--color-primary: #3b82f6;
--color-background: #ffffff;
--font-sans: 'Inter', system-ui, sans-serif;
--radius-md: 0.5rem;
}
.button {
background: var(--color-primary);
border-radius: var(--radius-md);
font-family: var(--font-sans);
}Tailwind CSS
Tokens map directly to your config:
// tailwind.config.ts
export default {
theme: {
extend: {
colors: {
primary: {
DEFAULT: '#3b82f6',
hover: '#2563eb',
},
background: '#ffffff',
},
fontFamily: {
sans: ['Inter', 'system-ui', 'sans-serif'],
},
borderRadius: {
md: '0.5rem',
},
},
},
}JavaScript/TypeScript
For JS-based styling (styled-components, Emotion):
// tokens.ts
export const tokens = {
color: {
primary: '#3b82f6',
background: '#ffffff',
},
font: {
sans: "'Inter', system-ui, sans-serif",
},
radius: {
md: '0.5rem',
},
} as constDark mode with tokens
Tokens make dark mode trivial. You swap semantic values, not primitive ones:
:root {
--color-background: #ffffff;
--color-foreground: #0f172a;
--color-muted: #64748b;
}
.dark {
--color-background: #0f172a;
--color-foreground: #f8fafc;
--color-muted: #94a3b8;
}Your components don't change. They reference --color-background and get the right value automatically.
Common mistakes
1. Too many tokens
Every token is a decision to maintain. Don't tokenize everything. padding: 1rem doesn't need a token if it's only used once.
2. Poor naming
--blue-500 is a primitive, not a semantic token. What happens when your brand switches to purple? Use --color-primary instead.
3. No documentation
Tokens are useless if your team doesn't know they exist. Document when to use text-muted vs text-secondary.
4. Inconsistent application If half your codebase uses tokens and half uses hardcoded values, you've gained complexity without the benefits.
Getting started
You don't need to build a token system from scratch. Tools like:
- Style Dictionary — Amazon's token build system
- Figma Tokens — Sync tokens between Figma and code
- OneMinuteBranding Design Tokens Generator — Free tool to define and export tokens in 5 formats (W3C, Style Dictionary, CSS, Tailwind, Figma)
- OneMinuteBranding — Generates tokens as part of your brand kit
The fastest path: use a design tokens generator to create your token set, export to your framework's format, and start building. Need colors first? Try the brand color palette generator to find your brand hues.
Design tokens aren't overhead. They're the foundation that makes your UI consistent, maintainable, and ready to scale.
Vibe coder & Indie Hacker. Building tools to help devs ship faster. Creator of OneMinuteBranding.
Ready to create your brand?
Generate a complete brand system with Tailwind config in 60 seconds.
Generate your brand