Design Tokens

Design Tokens are design values (colors, sizes, spacing) defined as variables. By referencing token names (--color-primary) instead of raw values (#1E40AF), we ensure consistency and maintainability.

Token Hierarchy

Global Tokens (Raw values)

Lowest level. Defines raw color/size values

--blue-600: #2563EB

Semantic Tokens (Purpose-based)

Abstraction based on meaning/purpose

--color-primary: var(--blue-600)

Component Tokens (Component-specific)

Component-specific tokens applied to component parts

--button-primary-bg: var(--color-primary)

Why Token Hierarchy?

ProblemSolution via Token Hierarchy
"Change blue" → 100 editsChange Global Token in 1 place
"Change only Primary button color"Change Component Token, no side effects
"What does this blue mean?"Semantic Token name conveys intent
"Add dark mode support"Switch Semantic Tokens by theme

Naming Convention

--{category}-{property}-{variant}-{state}
PartDescriptionExample
categoryToken categorycolor, spacing, radius, shadow
propertySpecific propertybackground, border, text
variantVariation (optional)primary, secondary, muted
stateState (optional)hover, active, disabled

Examples:

--color-background          /* category + property */
--color-background-muted    /* + variant */
--color-border-input-focus  /* + state */

Tailwind CSS v4 Integration

Tailwind CSS v4 deeply integrates with CSS custom properties.

Tailwind ClassCSS VariableValue
bg-backgroundvar(--background)#FFFFFF
text-foregroundvar(--foreground)#0A0A0A
bg-primaryvar(--primary)#1E3A8A
text-muted-foregroundvar(--muted-foreground)#737373
border-inputvar(--input)#E5E5E5
ring-ringvar(--ring)#3B82F6