Design

Design Tokens Explained for Developers Who've Never Worked with a Designer

N
Nicolas Maes
·February 2, 2026·9 min read

Design Tokens Explained for Developers Who've Never Worked with a Designer

A design token is a variable with opinions.

That's the entire concept. You've already used variables. You know that const maxRetries = 3 stores a value you can reference anywhere. A design token does the same thing, but the "value" is a design decision, and the "opinion" is the intent behind it.

Here's the distinction that matters for AI coding tools: --blue-500: #3B82F6 is a CSS variable. It stores a color value. --primary: var(--blue-500) is a design token. It stores the decision that "our primary action color is this specific blue."

When you're working solo, this distinction feels academic. When you're working with an AI tool that forgets context between generations, the distinction becomes critical.

The Three Layers of Design Tokens

Design tokens work in layers. Each layer builds on the previous one, and understanding the layers is the key to understanding why AI tools need them.

Reference Tokens (The Raw Values)

A reference token stores a value with no context. It's the bottom layer.

--blue-500: #3B82F6;
--blue-600: #2563EB;
--gray-100: #F3F4F6;
--gray-500: #6B7280;
--spacing-4: 1rem;
--radius-lg: 0.5rem;
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);

These are just values. They have no implied meaning. You're defining the raw materials of your design system. --blue-500 is a blue. That's all it says. Nothing about when to use it or why.

Reference tokens exist because you don't want to write #3B82F6 in 47 files. You define it once and reference it everywhere.

Semantic Tokens (The Decisions)

A semantic token assigns meaning to a reference token. It says: "In our design system, this value represents this decision."

--primary: var(--blue-500);
--primary-dark: var(--blue-600);
--background: var(--gray-100);
--text-secondary: var(--gray-500);
--spacing-standard: var(--spacing-4);
--radius-default: var(--radius-lg);
--shadow-card: var(--shadow-md);

Now --primary isn't just a color. It's "our primary action color." Change the value later? You only change it in one place. But more importantly, you've documented intent. Anyone reading color: var(--primary) knows this is a primary action, not just a random blue.

This layer is where AI tools get confused. Claude reads color: var(--primary) and knows it's a primary action color. But Claude reads color: #3B82F6 and has no idea when to use it.

Component Tokens (The Instructions)

A component token applies a semantic decision to a specific component or element:

--button-primary-bg: var(--primary);
--button-primary-hover: var(--primary-dark);
--button-secondary-bg: transparent;
--input-border: var(--gray-300);
--input-placeholder-color: var(--gray-400);
--card-shadow: var(--shadow-card);
--card-background: white;

Now you're saying: "Buttons use this color scheme. Inputs use this border. Cards use this shadow." You're instructing the components themselves, not just defining colors.

For AI tools, this layer is gold. Component-level tokens are self-documenting. var(--button-primary-bg) tells Claude exactly what this is for. #3B82F6 tells it nothing.

Design Tokens vs CSS Variables: What's the Actual Difference?

This is the question that trips up most developers. They sound like the same thing. Sometimes they are.

A CSS variable is a mechanism. It's how you store values in CSS:

:root {
  --blue: #3B82F6;
}

.button {
  background-color: var(--blue);
}

A design token is a concept. It's the semantic layer—the meaning behind the variable.

Here's the distinction: design tokens are design decisions. CSS variables are implementation details.

Design tokens and CSS variables are related but different. A CSS variable is the mechanism: --blue-500: #3B82F6. A design token is the concept: --primary: var(--blue-500) with the semantic meaning "this is our primary action color for buttons, links, and focus rings." CSS variables store values. Design tokens store decisions. The distinction matters for AI tools because --primary is self-documenting while --blue-500 requires context the AI doesn't have.

LayerExampleWhat It MeansWhen It Changes
Reference--blue-500: #3B82F6"This shade of blue exists"Almost never
Semantic--primary: var(--blue-500)"Our brand action color is this blue"When branding changes
Component--button-bg: var(--primary)"Buttons use our brand color"When component design changes

You can use CSS variables without design tokens. You'll end up with --blue-500, --blue-600, etc., everywhere. Your code will work, but AI tools won't understand the intent.

You can't use design tokens without CSS variables (well, you can in Figma or a design tool, but in code, you need the CSS mechanism). Design tokens live on top of CSS variables.

Why AI Coding Tools Need Design Tokens More Than Humans Do

A human designer looks at a comp and understands: "This button is primary. It should use the brand color." They don't need to read --primary. They see the visual hierarchy and know what to do.

An AI tool has no visual hierarchy understanding. It reads your code, sees patterns, and generates new code based on those patterns. If your code doesn't explicitly say "this is primary," the AI has to guess.

Here's what happens without design tokens:

You write:

<button style={{ backgroundColor: '#3B82F6', padding: '12px 24px' }}>
  Click me
</button>

Claude sees this and learns: "Buttons are blue and have 12px padding." But is it primary? Secondary? Destructive? Claude doesn't know. On the next generation, it might generate an entirely different color because there's no signal about what this blue represents.

Now imagine the same button with tokens:

<button style={{ backgroundColor: 'var(--button-primary-bg)', padding: 'var(--button-primary-padding)' }}>
  Click me
</button>

Claude sees this and learns: "Primary buttons use this token. When I generate another button marked as primary, use the same token." The semantic meaning is explicit.

Design tokens are documentation for AI tools. They say: "Here's what this decision means. Respect it on every generation."

Setting Up a Basic Token System in 15 Minutes

You don't need a designer to set up tokens. You need to make intentional choices.

Step 1: Define Your Reference Tokens

Pick values for colors, spacing, shadows, and typography. If you don't have strong opinions, use Tailwind's defaults as a starting point and modify from there.

Create a file called tokens.css:

/* Color Reference Tokens */
:root {
  --brand-color: hsl(220, 100%, 50%); /* Your brand color */
  --neutral-50: #FAFAFA;
  --neutral-100: #F3F4F6;
  --neutral-400: #9CA3AF;
  --neutral-900: #111827;

  /* Spacing */
  --space-2: 0.5rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;

  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 1rem;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

  /* Typography */
  --font-sans: system-ui, -apple-system, sans-serif;
  --font-mono: 'Courier New', monospace;
}

Spend 5 minutes choosing these values. Pick your brand color. Pick how much spacing you want (tight or loose). Pick how many shadow depths (typically 3-5). Done.

Step 2: Add Semantic Layers

Create another section in the same file (or a new tokens-semantic.css) that assigns meaning:

:root {
  /* Colors */
  --color-primary: var(--brand-color);
  --color-secondary: var(--neutral-400);
  --color-background: var(--neutral-50);
  --color-surface: white;
  --color-text: var(--neutral-900);
  --color-text-secondary: var(--neutral-400);

  /* Spacing */
  --spacing-tight: var(--space-2);
  --spacing-standard: var(--space-4);
  --spacing-loose: var(--space-8);

  /* Shadows */
  --shadow-raised: var(--shadow-md);
  --shadow-floating: var(--shadow-lg);
}

This takes 3 minutes. You're just assigning names to your reference tokens.

Step 3: Wire Up Tailwind v4 @theme

If you're using Tailwind v4, you can use the @theme directive to import your tokens:

/* globals.css or tailwind.config.js */

@theme {
  --color-primary: var(--color-primary);
  --color-secondary: var(--color-secondary);
  --radius-default: var(--radius-md);
  --shadow-raised: var(--shadow-raised);
}

This tells Tailwind to use your tokens as its theme values. Now when you use Tailwind classes like bg-primary or shadow-raised, you're using your design tokens, not Tailwind's defaults.

If you're using Tailwind v3, update your tailwind.config.js:

module.exports = {
  theme: {
    extend: {
      colors: {
        primary: 'var(--color-primary)',
        secondary: 'var(--color-secondary)',
      },
      borderRadius: {
        default: 'var(--radius-default)',
      },
      boxShadow: {
        raised: 'var(--shadow-raised)',
      },
    },
  },
}

That's 4 minutes.

Step 4: Add to Your AI Rules File

Update your CLAUDE.md or .cursorrules with your token values:

## Design Tokens

Always use these CSS variables:

- Primary color: var(--color-primary)
- Secondary: var(--color-secondary)
- Background: var(--color-background)
- Borders: var(--radius-default)
- Shadows on cards: var(--shadow-raised)
- Text: var(--color-text)

Example:
```jsx
<button className="bg-primary text-white px-4 py-2 rounded-default">
  Action
</button>

If you're using Tailwind with token support, you can simplify: "Always use Tailwind classes with token values: bg-primary, text-text, shadow-raised, rounded-default."

That's 3 minutes.

Total setup time: 15 minutes. You've gone from "AI tools generate random values" to "AI tools use consistent tokens."

Frequently Asked Questions

Q: What is a design token in simple terms?

A: A design token is a named variable that stores a design decision. Instead of writing color: #3B82F6 in 47 files, you define --primary: #3B82F6 once and reference it everywhere. The "token" part means it carries meaning: this isn't just a blue color, it's your primary action color. Change it once, it updates everywhere. That's the entire concept.

Q: Are design tokens the same as CSS variables?

A: CSS variables are the technical mechanism; design tokens are the conceptual layer on top. A CSS variable stores a value (--blue-500: #3B82F6). A design token adds meaning (--primary: var(--blue-500) means "this is our brand action color"). AI tools especially need that meaning layer because --primary is self-documenting while --blue-500 tells the AI nothing about when to use it.

Q: Do I need design tokens for a small project?

A: Even a 3-page project benefits from 10-15 tokens (5 colors, 3 radius values, 2 shadows, 1 font stack). The setup takes 15 minutes. Without tokens, AI tools pick different values on each generation, creating visual drift. With tokens, every page stays consistent automatically. The smaller the project, the faster the setup and the more obvious the improvement.

Q: How many design tokens do I need?

A: A minimal effective set is 15-20 tokens: 5 color tokens (primary, secondary, background, foreground, muted), 3 border-radius tokens (sm, md, lg), 3 shadow tokens (sm, md, lg), 2 font tokens (sans, mono), and 2-3 spacing tokens. This covers 90% of visual decisions. Matchkit's generated token set uses about 40 tokens for comprehensive coverage.

Q: Should I use design tokens even if I'm not using AI tools?

A: Yes, but for different reasons. Without AI tools, tokens reduce repetition and make theming easier. You change a color in one place, and it updates everywhere. With AI tools, tokens become communication. They tell Claude exactly what to use and when. Either way, 15 minutes of setup saves hours of refactoring later.

Q: Can I use design tokens with frameworks other than Tailwind?

A: Absolutely. Tokens work with any CSS. Define them in a CSS file, and reference them in any CSS-in-JS solution, Styled Components, Emotion, or plain CSS. The concept is the same: store design decisions in named variables and reference them consistently. The CSS custom properties syntax works everywhere.

Design tokens aren't complicated. They're just intentional naming. When you name something --primary instead of --blue-500, you're adding semantic meaning. For humans, that's clarity. For AI tools, it's the difference between consistent output and visual drift.

Start with 15 minutes and 15-20 tokens. Notice how much more consistent your AI-generated code becomes. Then expand from there.

#design-tokens#css-variables#tailwind#ai-coding#tutorial
All articles

More articles

Design

MCP Servers for Design: How AI Coding Tools Are Getting a Taste Layer

April 5, 2026·7 min read
Case Study

The Design Gap Between $0/mo and $49/mo SaaS (It's 11 CSS Values)

April 2, 2026·7 min read
Case Study

Agency Workflow: From Client Brief to Branded Prototype with AI Coding

March 29, 2026·7 min read