UI Design System
1. Design Token Generation
Token Format: W3C DTCG (2025.10)
Use the W3C Design Token Community Group format as the canonical interchange format for tokens:
{
"color": {
"brand": {
"primary": {
"$type": "color",
"$value": "oklch(0.65 0.25 265)",
"$description": "Primary brand color"
}
}
}
}
Key conventions:
$type declares the token type (color, dimension, fontFamily, fontWeight, etc.)
$value holds the resolved value
- Group nesting replaces flat naming (e.g.,
color.brand.primary not color-brand-primary)
- Use Style Dictionary (v4+) to transform DTCG tokens into platform outputs (CSS, iOS, Android, Figma)
Semantic Token Naming (Four-Part Hierarchy)
Structure token names as: category.concept.property.modifier
| Part |
Examples |
| Category |
color, space, font, border, shadow |
| Concept |
brand, neutral, feedback, surface |
| Property |
base, foreground, background, border |
| Modifier |
default, hover, active, disabled, subtle |
Examples: color.brand.background.default, color.feedback.error.foreground, space.layout.gap.lg
Color System
From a single brand color, generate a full palette:
| Step |
Brightness |
Use Case |
| 50 |
95% |
Subtle backgrounds |
| 100–200 |
90–85% |
Light backgrounds, hover states |
| 300–400 |
75–65% |
Borders, disabled states |
| 500 |
Original |
Base/default color |
| 600–700 |
80–60% of original |
Hover (dark), active states |
| 800–900 |
40–20% of original |
Text, headings |
Wide-Gamut Color Spaces
Oklch is the preferred perceptually uniform color space for design tokens. It provides consistent lightness across hues, making palette generation predictable:
/* Oklch: lightness, chroma, hue */
--color-brand-500: oklch(0.65 0.25 265);
--color-brand-600: oklch(0.55 0.25 265); /* Darken by reducing L */
/* Display P3 fallback for broader gamut */
--color-accent: color(display-p3 0.2 0.5 1.0);
- Use
oklch() for new projects; it's supported in all modern browsers (2024+)
- Use
color(display-p3 ...) for vivid colors beyond sRGB gamut
- Always provide an sRGB fallback with
@supports or CSS color() fallback syntax
Typography Scale (1.25x Ratio)
| Token |
Size |
Calculation |
| xs |
10px |
base ÷ 1.25² |
| sm |
13px |
base ÷ 1.25¹ |
| base |
16px |
Base |
| lg |
20px |
base × 1.25¹ |
| xl |
25px |
base × 1.25² |
| 2xl |
31px |
base × 1.25³ |
| 3xl |
39px |
base × 1.25⁴ |
Spacing (8pt Grid)
Base unit: 8px. Scale: 0, 4, 8, 12, 16, 24, 32, 48, 64.
Export Formats
# CSS custom properties
python scripts/design_token_generator.py "#0066CC" modern css > design-tokens.css
# SCSS variables
python scripts/design_token_generator.py "#0066CC" modern scss > _design-tokens.scss
# JSON (for Figma/tooling)
python scripts/design_token_generator.py "#0066CC" modern json > design-tokens.json
2. Component Architecture (Atomic Design)
| Level |
Examples |
Tokens Used |
| Atoms |
Button, Input, Icon, Badge |
colors, sizing, borders, typography |
| Molecules |
FormField, SearchBar, Card |
atoms + spacing, shadows |
| Organisms |
Header, DataTable, Modal |
molecules + layout, z-index |
| Templates |
DashboardLayout, AuthLayout |
organisms + grid, breakpoints |
Variant Patterns
Size:
sm: height 32px, paddingX 12px, fontSize 14px
md: height 40px, paddingX 16px, fontSize 16px
lg: height 48px, paddingX 20px, fontSize 18px
Color:
primary: background primary-500, text white
secondary: background neutral-100, text neutral-900
ghost: background transparent, text neutral-700
3. Responsive Design
Breakpoints
| Name |
Width |
Target |
| xs |
0 |
Small phones |
| sm |
480px |
Large phones |
| md |
640px |
Tablets |
| lg |
768px |
Small laptops |
| xl |
1024px |
Desktops |
| 2xl |
1280px |
Large screens |
Fluid Typography
--fluid-h1: clamp(2rem, 1rem + 3.6vw, 4rem);
--fluid-h2: clamp(1.75rem, 1rem + 2.3vw, 3rem);
--fluid-body: clamp(1rem, 0.95rem + 0.2vw, 1.125rem);
4. WCAG Accessibility
Contrast Requirements
| Level |
Normal Text |
Large Text (≥18pt / ≥14pt bold) |
| AA |
4.5:1 |
3:1 |
| AAA |
7:1 |
4.5:1 |
Checklist
5. Developer Handoff
Framework Integration
React + CSS Variables:
import './design-tokens.css';
<button className="btn btn-primary">Click</button>
Tailwind Config:
const tokens = require('./design-tokens.json');
module.exports = { theme: { colors: tokens.colors, fontFamily: tokens.typography.fontFamily } };
Handoff Checklist
Style Presets
| Aspect |
Modern |
Classic |
Playful |
| Font Sans |
Inter |
Helvetica |
Poppins |
| Font Mono |
Fira Code |
Courier |
Source Code Pro |
| Border Radius |
8px |
4px |
16px |
| Shadows |
Layered, subtle |
Single layer |
Soft, pronounced |
Tooling Reference
1---2name: ui-design-system3description: Design token generation, color palettes, typography scales, component architecture, WCAG accessibility, and developer handoff. Use when creating design systems, maintaining visual consistency, or bridging design-development collaboration.4---56# UI Design System78---910## 1. Design Token Generation1112### Token Format: W3C DTCG (2025.10)1314Use the **W3C Design Token Community Group** format as the canonical interchange format for tokens:1516```json17{18 "color": {19 "brand": {20 "primary": {21 "$type": "color",22 "$value": "oklch(0.65 0.25 265)",23 "$description": "Primary brand color"24 }25 }26 }27}28```2930Key conventions:31- `$type` declares the token type (color, dimension, fontFamily, fontWeight, etc.)32- `$value` holds the resolved value33- Group nesting replaces flat naming (e.g., `color.brand.primary` not `color-brand-primary`)34- Use **Style Dictionary** (v4+) to transform DTCG tokens into platform outputs (CSS, iOS, Android, Figma)3536### Semantic Token Naming (Four-Part Hierarchy)3738Structure token names as: **category.concept.property.modifier**3940| Part | Examples |41|------|----------|42| Category | `color`, `space`, `font`, `border`, `shadow` |43| Concept | `brand`, `neutral`, `feedback`, `surface` |44| Property | `base`, `foreground`, `background`, `border` |45| Modifier | `default`, `hover`, `active`, `disabled`, `subtle` |4647Examples: `color.brand.background.default`, `color.feedback.error.foreground`, `space.layout.gap.lg`4849### Color System5051From a single brand color, generate a full palette:5253| Step | Brightness | Use Case |54|------|------------|----------|55| 50 | 95% | Subtle backgrounds |56| 100–200 | 90–85% | Light backgrounds, hover states |57| 300–400 | 75–65% | Borders, disabled states |58| 500 | Original | Base/default color |59| 600–700 | 80–60% of original | Hover (dark), active states |60| 800–900 | 40–20% of original | Text, headings |6162### Wide-Gamut Color Spaces6364**Oklch** is the preferred perceptually uniform color space for design tokens. It provides consistent lightness across hues, making palette generation predictable:6566```css67/* Oklch: lightness, chroma, hue */68--color-brand-500: oklch(0.65 0.25 265);69--color-brand-600: oklch(0.55 0.25 265); /* Darken by reducing L */7071/* Display P3 fallback for broader gamut */72--color-accent: color(display-p3 0.2 0.5 1.0);73```7475- Use `oklch()` for new projects; it's supported in all modern browsers (2024+)76- Use `color(display-p3 ...)` for vivid colors beyond sRGB gamut77- Always provide an sRGB fallback with `@supports` or CSS `color()` fallback syntax7879### Typography Scale (1.25x Ratio)8081| Token | Size | Calculation |82|-------|------|-------------|83| xs | 10px | base ÷ 1.25² |84| sm | 13px | base ÷ 1.25¹ |85| base | 16px | Base |86| lg | 20px | base × 1.25¹ |87| xl | 25px | base × 1.25² |88| 2xl | 31px | base × 1.25³ |89| 3xl | 39px | base × 1.25⁴ |9091### Spacing (8pt Grid)9293Base unit: 8px. Scale: 0, 4, 8, 12, 16, 24, 32, 48, 64.9495### Export Formats9697```bash98# CSS custom properties99python scripts/design_token_generator.py "#0066CC" modern css > design-tokens.css100101# SCSS variables102python scripts/design_token_generator.py "#0066CC" modern scss > _design-tokens.scss103104# JSON (for Figma/tooling)105python scripts/design_token_generator.py "#0066CC" modern json > design-tokens.json106```107108---109110## 2. Component Architecture (Atomic Design)111112| Level | Examples | Tokens Used |113|-------|----------|-------------|114| Atoms | Button, Input, Icon, Badge | colors, sizing, borders, typography |115| Molecules | FormField, SearchBar, Card | atoms + spacing, shadows |116| Organisms | Header, DataTable, Modal | molecules + layout, z-index |117| Templates | DashboardLayout, AuthLayout | organisms + grid, breakpoints |118119### Variant Patterns120121**Size:**122```123sm: height 32px, paddingX 12px, fontSize 14px124md: height 40px, paddingX 16px, fontSize 16px125lg: height 48px, paddingX 20px, fontSize 18px126```127128**Color:**129```130primary: background primary-500, text white131secondary: background neutral-100, text neutral-900132ghost: background transparent, text neutral-700133```134135---136137## 3. Responsive Design138139### Breakpoints140141| Name | Width | Target |142|------|-------|--------|143| xs | 0 | Small phones |144| sm | 480px | Large phones |145| md | 640px | Tablets |146| lg | 768px | Small laptops |147| xl | 1024px | Desktops |148| 2xl | 1280px | Large screens |149150### Fluid Typography151152```css153--fluid-h1: clamp(2rem, 1rem + 3.6vw, 4rem);154--fluid-h2: clamp(1.75rem, 1rem + 2.3vw, 3rem);155--fluid-body: clamp(1rem, 0.95rem + 0.2vw, 1.125rem);156```157158---159160## 4. WCAG Accessibility161162### Contrast Requirements163164| Level | Normal Text | Large Text (≥18pt / ≥14pt bold) |165|-------|-------------|---------|166| AA | 4.5:1 | 3:1 |167| AAA | 7:1 | 4.5:1 |168169### Checklist170- [ ] Color contrast meets WCAG AA171- [ ] Focus indicators visible on all interactive elements172- [ ] Touch targets ≥ 44×44px173- [ ] Semantic HTML elements used174- [ ] All images have alt text175176---177178## 5. Developer Handoff179180### Framework Integration181182**React + CSS Variables:**183```tsx184import './design-tokens.css';185<button className="btn btn-primary">Click</button>186```187188**Tailwind Config:**189```javascript190const tokens = require('./design-tokens.json');191module.exports = { theme: { colors: tokens.colors, fontFamily: tokens.typography.fontFamily } };192```193194### Handoff Checklist195- [ ] Token files added to project196- [ ] Theme imported in app entry point197- [ ] Component library uses tokens only (no hardcoded values)198- [ ] Documentation generated199200---201202## Style Presets203204| Aspect | Modern | Classic | Playful |205|--------|--------|---------|---------|206| Font Sans | Inter | Helvetica | Poppins |207| Font Mono | Fira Code | Courier | Source Code Pro |208| Border Radius | 8px | 4px | 16px |209| Shadows | Layered, subtle | Single layer | Soft, pronounced |210211---212213## Tooling Reference214215| Tool | Purpose |216|------|---------|217| [Style Dictionary](https://styledictionary.com/) (v4+) | Transform DTCG tokens to CSS, iOS, Android, Compose |218| [Figma Variables](https://help.figma.com/hc/en-us/articles/15339657135383) | Design-side token management and theming |219| [Cobalt UI](https://cobalt-ui.pages.dev/) | DTCG-native token pipeline alternative |220| [Tokens Studio](https://tokens.studio/) | Figma plugin for syncing tokens to/from code |