# Design Token Architecture **Purpose:** Core principles for separating semantic structure from visual style. **Referenced by:** All component-type instructions --- ## Core Principle **Separate semantic structure from visual style.** ``` HTML/Structure = Meaning (what it is) Design Tokens = Appearance (how it looks) They should be independent! ``` --- ## The Problem **Bad Practice:** ```html

Heading

``` **Issues:** - Visual styling mixed with semantic HTML - Can't change h2 appearance without changing all h2s - h2 means "second-level heading" but looks like "display large" - Breaks separation of concerns --- ## The Solution **Good Practice:** **HTML (Semantic):** ```html

Heading

``` **Design Tokens (Visual):** ```css .heading-section { font-size: var(--text-4xl); font-weight: var(--font-bold); color: var(--color-primary-600); } ``` **Benefits:** - Semantic HTML stays semantic - Visual style is centralized - Can change appearance without touching HTML - Clear separation of concerns --- ## Token Hierarchy ### Level 1: Raw Values ```css --spacing-4: 1rem; --color-blue-600: #2563eb; --font-size-4xl: 2.25rem; ``` ### Level 2: Semantic Tokens ```css --text-heading-large: var(--font-size-4xl); --color-primary: var(--color-blue-600); --spacing-section: var(--spacing-4); ``` ### Level 3: Component Tokens ```css --button-padding-x: var(--spacing-section); --button-color-primary: var(--color-primary); --heading-size-section: var(--text-heading-large); ``` **Use Level 2 or 3 in components, never Level 1 directly.** --- ## Application to WDS ### In Page Specifications **Specify semantic structure:** ```yaml Page Structure: - Section Heading (h2) - Body text (p) - Primary button (button) ``` **NOT visual styling:** ```yaml # ❌ Don't do this Page Structure: - Large blue bold text - 16px gray text - Blue rounded button ``` ### In Design System **Specify visual styling:** ```yaml Section Heading: html_element: h2 design_token: heading-section Design Token Definition: heading-section: font-size: text-4xl font-weight: bold color: primary-600 ``` --- ## Component-Type Instructions ### Text Heading Example **When specifying a heading:** 1. **Identify semantic level** (h1-h6) - h1 = Page title - h2 = Section heading - h3 = Subsection heading - etc. 2. **Map to design token** - h1 → display-large - h2 → heading-section - h3 → heading-subsection 3. **Store separately** - Page spec: `

` (semantic) - Design system: `heading-section` token (visual) **Example Output:** **Page Spec:** ```yaml Hero Section: heading: element: h2 token: heading-section content: 'Welcome to Our Product' ``` **Design System:** ```yaml Tokens: heading-section: font-size: 2.25rem font-weight: 700 line-height: 1.2 color: gray-900 ``` --- ## Button Example **When specifying a button:** 1. **Identify semantic element** - `