Skip to content

Understanding Design Tokens

Design tokens are the single source of truth for your design system's visual properties. This page explains what they are, why they matter, and how to document them effectively.

What are design tokens?

A design token is a named value that represents a design decision. Instead of using raw values like #2563eb throughout your codebase, you assign it a semantic name like primary and reference the token everywhere.

ColorTokenCSS Variable
#2563eb
primary--color-primary

The token primary always resolves to #2563eb. When the brand color changes, you update it in one place and the entire system follows.

Why use design tokens?

Consistency

Without tokens, the same blue might appear as #2563eb in one file, #2564eb in another (a typo), and rgb(37, 99, 235) in a third. Tokens eliminate this drift.

Semantic meaning

Raw colors don't communicate intent. #dc2626 could be anything — but danger tells you exactly what it's for. This makes code reviews easier and prevents misuse.

Theming

Tokens decouple intent from value. The token background can resolve to #ffffff in light mode and #0a0a0a in dark mode:

TokenLightDark
background
#ffffff
#0a0a0a
surface
#f5f5f5
#171717
text
#1e293b
#f8fafc
muted
#64748b
#94a3b8

Handoff

Tokens bridge the gap between design and development. Designers define primary-500, developers consume --color-primary-500. Both speak the same language.

Anatomy of a design token

A well-defined token typically has:

PartExamplePurpose
NameprimaryHuman-readable identifier
Value#2563ebThe actual color
CSS variable--color-primaryHow it's consumed in code
Purpose"Primary brand color"When to use (and when not to)

The Token Table feature lets you document all of these in a single block:

ColorTokenCSS VariablePurpose
#2563eb
primary--color-primaryButtons, links, CTA
#dc2626
danger--color-dangerErrors, destructive
#16a34a
success--color-successConfirmations, valid
#d97706
warning--color-warningCaution, attention

Token naming conventions

There's no single right way to name tokens, but most systems follow a pattern:

Flat naming

Simple and direct. Works well for small systems.

ColorToken
#2563eb
primary
#1d4ed8
primaryHover
#dc2626
danger
#16a34a
success

Scale naming

Uses numeric scales (like Tailwind). Good for precise control over shades.

ColorToken
#dbeafe
blue-100
#93c5fd
blue-300
#3b82f6
blue-500
#1d4ed8
blue-700
#1e3a8a
blue-900

Semantic + role naming

Separates palette from purpose. The most scalable approach.

ColorTokenUsage
#2563eb
action-primaryPrimary buttons
#1d4ed8
action-primary-hoverPrimary button hover
#dc2626
feedback-errorError messages
#16a34a
feedback-successSuccess confirmations
#f8fafc
surface-pagePage background
#f1f5f9
surface-cardCard background

Documenting with this plugin

This plugin gives you several ways to document your tokens:

FeatureBest for
Token Table (:::colors)Full token reference with metadata columns
Color Palettes (:::colors)Quick visual overview of a color set
Color Strips (:::colors-strip)Showing gradients and sequential scales
Token Comparison (:::colors-compare)Comparing states, variants, or scales
Contrast Checker (:::colors-contrast)Validating accessibility of fg/bg pairs

Tips

  1. Document every token — if it's in the code, it should be in the docs. Undocumented tokens get misused.
  2. Show context, not just color — include the CSS variable name and a short purpose so developers know how to use it.
  3. Group logically — separate brand colors, status colors, surface colors, and text colors into their own tables.
  4. Check contrast — use the Contrast Checker to verify that your text/background pairs meet WCAG standards.
  5. Keep it updated — token docs that drift from reality are worse than no docs at all.