Capítulo 11 de 17

Chapter 11: Design Tokens

Core Idea

Design tokens are the named, platform-agnostic values (a color, a spacing unit, a font size, a shadow) that encode a design system's visual decisions once and distribute them everywhere — the modern, formalized version of the "invisible atoms" from Atomic Design.

Key Concepts

  • Token categories: color (brand palette, semantic colors like color.danger), typography (font family/size/weight/line-height scales), spacing (a consistent numeric scale, e.g. 4px/8px-based), sizing (component dimensions, breakpoints), elevation (shadow/z-index scales), motion (duration/easing curves), and border/radius values.
  • Semantic vs. primitive tokens: primitive tokens are raw values (blue-500 = #3B82F6); semantic tokens alias them to meaning (color.action.primary = blue-500) so a rebrand only needs to repoint the alias, not touch every usage.
  • W3C Design Tokens Community Group (DTCG) format: an emerging standard JSON structure for defining tokens ($value, $type, $description) so tokens are portable across tools rather than locked into one vendor's format.
  • Style Dictionary: a widely-used open-source tool (originally Amazon) that transforms a single token source of truth into per-platform output — CSS custom properties, iOS/Android native formats, Tailwind config, JS/TS constants — so every platform consumes the same values without manual duplication.
  • Token pipeline: design tool (e.g. Figma variables) → exported token source (JSON) → transform tool (Style Dictionary or similar) → platform-specific artifacts consumed by code.

Mental Models

Tokens are the single source of truth a rebrand or theme change should only ever touch once. If changing a brand color requires touching more than the token definition, the token layer isn't doing its job.

Prefer semantic tokens in component code, primitive tokens only in the token definitions themselves. Components should reference color.text.primary, never gray-900 directly — this is what makes theming (dark mode, brand variants) possible without touching component code.

Anti-patterns

  • Hardcoding raw values in components: bypasses the whole token system and reintroduces the inconsistency design tokens exist to prevent.
  • Skipping the semantic layer: using primitive tokens (blue-500) directly in components instead of semantic ones (color.action.primary) — works until a rebrand or theme forces a manual find-and-replace across the codebase.

Key Takeaways

  1. Design tokens are the machine-readable form of a system's atoms — the same "invisible" primitives Atomic Design already treats as atoms.
  2. Structure tokens in two layers: primitive (raw values) and semantic (meaningful aliases) — components should only ever reference the semantic layer.
  3. A transform tool (Style Dictionary or equivalent) turning one token source into every platform's native format is what keeps design and every codebase in sync without manual duplication.
  4. The W3C DTCG format is where the ecosystem is converging — worth targeting if starting a token system today, for tool portability.

Connects To

  • Ch 3 (Atoms): the conceptual ancestor of design tokens in Atomic Design.
  • tailwind-docs: Tailwind's @theme mechanism is a concrete implementation of semantic design tokens for a specific styling system.
  • Ch 12 (Component API Conventions): how token values surface as component props (size/tone/variant).