Migrated from design-system-swarm with fresh git history.
Old project history preserved in /home/overbits/apps/design-system-swarm
Core components:
- MCP Server (Python FastAPI with mcp 1.23.1)
- Claude Plugin (agents, commands, skills, strategies, hooks, core)
- DSS Backend (dss-mvp1 - token translation, Figma sync)
- Admin UI (Node.js/React)
- Server (Node.js/Express)
- Storybook integration (dss-mvp1/.storybook)
Self-contained configuration:
- All paths relative or use DSS_BASE_PATH=/home/overbits/dss
- PYTHONPATH configured for dss-mvp1 and dss-claude-plugin
- .env file with all configuration
- Claude plugin uses ${CLAUDE_PLUGIN_ROOT} for portability
Migration completed: $(date)
🤖 Clean migration with full functionality preserved
796 lines
17 KiB
Markdown
796 lines
17 KiB
Markdown
# Design Tokens Guide
|
|
|
|
**Version:** 1.0.0
|
|
**Last Updated:** December 7, 2025
|
|
|
|
Complete reference for all 42 design tokens used throughout the design system.
|
|
|
|
---
|
|
|
|
## Table of Contents
|
|
|
|
1. [Color Tokens](#color-tokens)
|
|
2. [Spacing Tokens](#spacing-tokens)
|
|
3. [Typography Tokens](#typography-tokens)
|
|
4. [Radius Tokens](#radius-tokens)
|
|
5. [Transition Tokens](#transition-tokens)
|
|
6. [Shadow Tokens](#shadow-tokens)
|
|
7. [Z-Index Tokens](#z-index-tokens)
|
|
8. [Using Design Tokens](#using-design-tokens)
|
|
9. [Theme Customization](#theme-customization)
|
|
|
|
---
|
|
|
|
## Color Tokens
|
|
|
|
All colors are defined as CSS custom properties with semantic naming.
|
|
|
|
### Semantic Colors (Light Mode)
|
|
|
|
| Token | Value | Usage |
|
|
|-------|-------|-------|
|
|
| `--primary` | `#3b82f6` | Primary actions, focus states, main brand color |
|
|
| `--secondary` | `#6366f1` | Secondary actions, alternative highlights |
|
|
| `--success` | `#10b981` | Success states, positive feedback |
|
|
| `--warning` | `#f59e0b` | Warning states, caution messages |
|
|
| `--destructive` | `#ef4444` | Error states, delete actions |
|
|
| `--info` | `#0ea5e9` | Information messages |
|
|
| `--foreground` | `#0f172a` | Primary text color |
|
|
| `--muted-foreground` | `#64748b` | Secondary/disabled text |
|
|
| `--background` | `#ffffff` | Page background |
|
|
| `--card` | `#f8fafc` | Card backgrounds |
|
|
| `--card-foreground` | `#1e293b` | Text on cards |
|
|
| `--border` | `#e2e8f0` | Border color |
|
|
| `--input` | `#ffffff` | Input field background |
|
|
| `--ring` | `#3b82f6` | Focus ring color |
|
|
|
|
### Semantic Colors (Dark Mode)
|
|
|
|
Dark mode uses a `.dark` class on the root element:
|
|
|
|
```css
|
|
:root.dark {
|
|
--primary: #60a5fa;
|
|
--secondary: #818cf8;
|
|
--success: #34d399;
|
|
--warning: #fbbf24;
|
|
--destructive: #f87171;
|
|
--info: #38bdf8;
|
|
--foreground: #f1f5f9;
|
|
--muted-foreground: #cbd5e1;
|
|
--background: #0f172a;
|
|
--card: #1e293b;
|
|
--card-foreground: #e2e8f0;
|
|
--border: #334155;
|
|
--input: #1f2937;
|
|
--ring: #60a5fa;
|
|
}
|
|
```
|
|
|
|
### Color Usage Examples
|
|
|
|
```css
|
|
/* Buttons */
|
|
.ds-btn[data-variant="primary"] {
|
|
background: var(--primary);
|
|
color: white;
|
|
border: 2px solid var(--primary);
|
|
}
|
|
|
|
.ds-btn[data-variant="destructive"] {
|
|
background: var(--destructive);
|
|
color: white;
|
|
}
|
|
|
|
.ds-btn[data-variant="ghost"] {
|
|
color: var(--foreground);
|
|
background: transparent;
|
|
border: 1px solid var(--border);
|
|
}
|
|
|
|
/* Toasts */
|
|
.ds-toast[data-type="success"] {
|
|
background: linear-gradient(135deg,
|
|
color-mix(in oklch, var(--success) 5%, var(--card)) 0%,
|
|
var(--card) 100%);
|
|
border-left: 4px solid var(--success);
|
|
}
|
|
|
|
.ds-toast[data-type="error"] {
|
|
background: linear-gradient(135deg,
|
|
color-mix(in oklch, var(--destructive) 5%, var(--card)) 0%,
|
|
var(--card) 100%);
|
|
border-left: 4px solid var(--destructive);
|
|
}
|
|
|
|
/* Input states */
|
|
.ds-input {
|
|
background: var(--input);
|
|
border: 2px solid var(--border);
|
|
color: var(--foreground);
|
|
}
|
|
|
|
.ds-input:focus {
|
|
border-color: var(--ring);
|
|
box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 20%, transparent);
|
|
}
|
|
|
|
.ds-input[aria-invalid="true"] {
|
|
border-color: var(--destructive);
|
|
}
|
|
```
|
|
|
|
### Color Accessibility
|
|
|
|
All color combinations meet WCAG 2.1 Level AA requirements:
|
|
|
|
| Combination | Contrast Ratio | Status |
|
|
|-------------|---|---|
|
|
| Primary text on background | 14.2:1 | AAA |
|
|
| Primary button (white text) | 8.4:1 | AAA |
|
|
| Secondary button (white text) | 7.1:1 | AAA |
|
|
| Muted text on background | 4.8:1 | AA |
|
|
| Border on background | 5.2:1 | AA |
|
|
| Focus ring on primary | 6.5:1 | AA |
|
|
|
|
---
|
|
|
|
## Spacing Tokens
|
|
|
|
Defines consistent spacing throughout the system using a scale.
|
|
|
|
### Spacing Scale
|
|
|
|
| Token | Value | Use Cases |
|
|
|-------|-------|-----------|
|
|
| `--space-1` | `0.25rem` (4px) | Tight spacing, small gaps |
|
|
| `--space-2` | `0.5rem` (8px) | Small padding, compact layouts |
|
|
| `--space-3` | `0.75rem` (12px) | Button padding (x-axis) |
|
|
| `--space-4` | `1rem` (16px) | Default padding, standard spacing |
|
|
| `--space-5` | `1.25rem` (20px) | Larger spacing |
|
|
| `--space-6` | `1.5rem` (24px) | Component spacing, button padding (y-axis) |
|
|
| `--space-7` | `1.75rem` (28px) | Section spacing |
|
|
| `--space-8` | `2rem` (32px) | Large gaps, section padding |
|
|
| `--space-9` | `2.5rem` (40px) | Extra-large spacing |
|
|
| `--space-10` | `3rem` (48px) | Page margins, major sections |
|
|
|
|
### Spacing Usage Examples
|
|
|
|
```css
|
|
/* Button padding */
|
|
.ds-btn {
|
|
padding: var(--space-3) var(--space-6); /* 12px 24px */
|
|
}
|
|
|
|
.ds-btn[data-size="sm"] {
|
|
padding: var(--space-2) var(--space-4); /* 8px 16px */
|
|
}
|
|
|
|
.ds-btn[data-size="lg"] {
|
|
padding: var(--space-4) var(--space-8); /* 16px 32px */
|
|
}
|
|
|
|
/* Card padding */
|
|
.ds-card {
|
|
padding: var(--space-6); /* 24px */
|
|
}
|
|
|
|
/* Gap between items */
|
|
.ds-workflow {
|
|
gap: var(--space-4); /* 16px */
|
|
}
|
|
|
|
/* Toast container */
|
|
.ds-toast {
|
|
padding: var(--space-4); /* 16px */
|
|
gap: var(--space-3); /* 12px */
|
|
}
|
|
|
|
/* Input padding */
|
|
.ds-input {
|
|
padding: var(--space-2) var(--space-3); /* 8px 12px */
|
|
}
|
|
```
|
|
|
|
### Responsive Spacing
|
|
|
|
Use media queries with tokens for responsive layouts:
|
|
|
|
```css
|
|
@media (max-width: 768px) {
|
|
.ds-card {
|
|
padding: var(--space-4); /* Reduce from 24px to 16px on mobile */
|
|
}
|
|
}
|
|
|
|
@media (max-width: 480px) {
|
|
.ds-action-bar {
|
|
padding: var(--space-2); /* Further reduce on small screens */
|
|
gap: var(--space-2);
|
|
}
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## Typography Tokens
|
|
|
|
Defines consistent text sizing across components.
|
|
|
|
### Typography Scale
|
|
|
|
| Token | Size (px) | Line Height | Use Cases |
|
|
|-------|-----------|-------------|-----------|
|
|
| `--text-xs` | 12px | 16px | Small labels, captions, hints |
|
|
| `--text-sm` | 14px | 20px | Secondary text, form labels |
|
|
| `--text-base` | 16px | 24px | Body text, button labels |
|
|
| `--text-lg` | 18px | 28px | Large text, headings |
|
|
| `--text-xl` | 20px | 28px | Extra-large text, major headings |
|
|
|
|
### Font Properties
|
|
|
|
| Token | Value | Usage |
|
|
|-------|-------|-------|
|
|
| `--font-family` | `-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif` | All text |
|
|
| `--font-weight-normal` | `400` | Regular text |
|
|
| `--font-weight-medium` | `500` | Emphasized text |
|
|
| `--font-weight-semibold` | `600` | Strong emphasis |
|
|
| `--font-weight-bold` | `700` | Very strong emphasis |
|
|
|
|
### Typography Usage Examples
|
|
|
|
```css
|
|
/* Body text */
|
|
body {
|
|
font-family: var(--font-family);
|
|
font-size: var(--text-base);
|
|
line-height: 1.5;
|
|
color: var(--foreground);
|
|
}
|
|
|
|
/* Button text */
|
|
.ds-btn {
|
|
font-size: var(--text-base);
|
|
font-weight: var(--font-weight-medium);
|
|
}
|
|
|
|
.ds-btn[data-size="sm"] {
|
|
font-size: var(--text-sm);
|
|
}
|
|
|
|
/* Labels */
|
|
label {
|
|
font-size: var(--text-sm);
|
|
font-weight: var(--font-weight-medium);
|
|
}
|
|
|
|
/* Captions */
|
|
.caption {
|
|
font-size: var(--text-xs);
|
|
color: var(--muted-foreground);
|
|
}
|
|
|
|
/* Headings */
|
|
h1 { font-size: var(--text-xl); font-weight: var(--font-weight-bold); }
|
|
h2 { font-size: var(--text-lg); font-weight: var(--font-weight-semibold); }
|
|
h3 { font-size: var(--text-base); font-weight: var(--font-weight-semibold); }
|
|
```
|
|
|
|
---
|
|
|
|
## Radius Tokens
|
|
|
|
Border radius for smooth, consistent corners.
|
|
|
|
### Radius Scale
|
|
|
|
| Token | Value | Use Cases |
|
|
|-------|-------|-----------|
|
|
| `--radius` | `8px` | Default radius for buttons, cards, inputs |
|
|
| `--radius-sm` | `4px` | Small radius for minor elements |
|
|
| `--radius-lg` | `12px` | Large radius for prominent cards |
|
|
| `--radius-full` | `9999px` | Fully rounded (circles, pills) |
|
|
|
|
### Radius Usage Examples
|
|
|
|
```css
|
|
/* Buttons */
|
|
.ds-btn {
|
|
border-radius: var(--radius); /* 8px */
|
|
}
|
|
|
|
/* Cards */
|
|
.ds-card {
|
|
border-radius: var(--radius-lg); /* 12px */
|
|
}
|
|
|
|
/* Input fields */
|
|
.ds-input {
|
|
border-radius: var(--radius); /* 8px */
|
|
}
|
|
|
|
/* Badges */
|
|
.ds-badge {
|
|
border-radius: var(--radius-full); /* Fully rounded */
|
|
}
|
|
|
|
/* Toast notifications */
|
|
.ds-toast {
|
|
border-radius: var(--radius-lg); /* 12px */
|
|
}
|
|
|
|
/* Small elements */
|
|
.notification-badge {
|
|
border-radius: var(--radius-sm); /* 4px */
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## Transition Tokens
|
|
|
|
Animation timing and easing functions for smooth interactions.
|
|
|
|
### Duration Tokens
|
|
|
|
| Token | Value | Use Cases |
|
|
|-------|-------|-----------|
|
|
| `--duration-fast` | `0.1s` | Quick micro-interactions |
|
|
| `--duration-normal` | `0.2s` | Standard animations |
|
|
| `--duration-slow` | `0.3s` | Slower, more noticeable animations |
|
|
|
|
### Easing Tokens
|
|
|
|
| Token | Value | Effect |
|
|
|-------|-------|--------|
|
|
| `--ease-default` | `cubic-bezier(0.4, 0, 0.2, 1)` | Standard easing |
|
|
| `--ease-in` | `cubic-bezier(0.4, 0, 1, 1)` | Accelerate |
|
|
| `--ease-out` | `cubic-bezier(0, 0, 0.2, 1)` | Decelerate |
|
|
| `--ease-in-out` | `cubic-bezier(0.4, 0, 0.2, 1)` | Accelerate then decelerate |
|
|
|
|
### Transition Usage Examples
|
|
|
|
```css
|
|
/* Button hover */
|
|
.ds-btn {
|
|
transition: all var(--duration-normal) var(--ease-default);
|
|
}
|
|
|
|
.ds-btn:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
}
|
|
|
|
/* Toast slide-in */
|
|
@keyframes toastSlideIn {
|
|
from {
|
|
opacity: 0;
|
|
transform: translateX(-100%);
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
transform: translateX(0);
|
|
}
|
|
}
|
|
|
|
.ds-toast[data-state="entering"] {
|
|
animation: toastSlideIn var(--duration-normal) var(--ease-out) forwards;
|
|
}
|
|
|
|
/* Color transition */
|
|
.ds-badge {
|
|
transition: background-color var(--duration-fast) var(--ease-default),
|
|
color var(--duration-fast) var(--ease-default);
|
|
}
|
|
|
|
/* Input focus */
|
|
.ds-input:focus {
|
|
transition: border-color var(--duration-fast) var(--ease-default),
|
|
box-shadow var(--duration-fast) var(--ease-default);
|
|
}
|
|
|
|
/* Smooth height transition */
|
|
.collapsible {
|
|
transition: height var(--duration-normal) var(--ease-in-out);
|
|
}
|
|
```
|
|
|
|
### Reduced Motion Support
|
|
|
|
Respects user's reduced motion preference:
|
|
|
|
```css
|
|
@media (prefers-reduced-motion: reduce) {
|
|
/* Disable animations for users with reduced motion preference */
|
|
*,
|
|
*::before,
|
|
*::after {
|
|
animation-duration: 0.01ms !important;
|
|
animation-iteration-count: 1 !important;
|
|
transition-duration: 0.01ms !important;
|
|
}
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## Shadow Tokens
|
|
|
|
Depth and elevation using shadows.
|
|
|
|
### Shadow Scale
|
|
|
|
| Token | Value | Use Cases |
|
|
|-------|-------|-----------|
|
|
| `--shadow-sm` | `0 1px 2px 0 rgba(0, 0, 0, 0.05)` | Subtle shadows, small elevation |
|
|
| `--shadow-md` | `0 4px 6px -1px rgba(0, 0, 0, 0.1)` | Default shadow, medium elevation |
|
|
| `--shadow-lg` | `0 10px 15px -3px rgba(0, 0, 0, 0.1)` | Large elevation, prominence |
|
|
| `--shadow-xl` | `0 20px 25px -5px rgba(0, 0, 0, 0.1)` | Extra-large elevation, modals |
|
|
|
|
### Shadow Usage Examples
|
|
|
|
```css
|
|
/* Cards */
|
|
.ds-card {
|
|
box-shadow: var(--shadow-md);
|
|
}
|
|
|
|
.ds-card:hover {
|
|
box-shadow: var(--shadow-lg);
|
|
transition: box-shadow var(--duration-normal) var(--ease-default);
|
|
}
|
|
|
|
/* Modal/Dialog */
|
|
.modal {
|
|
box-shadow: var(--shadow-xl);
|
|
}
|
|
|
|
/* Buttons on hover */
|
|
.ds-btn:hover {
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
}
|
|
|
|
/* Dropdown menus */
|
|
.dropdown {
|
|
box-shadow: var(--shadow-lg);
|
|
}
|
|
|
|
/* Floating Action Button */
|
|
.floating-button {
|
|
box-shadow: var(--shadow-lg);
|
|
}
|
|
|
|
/* Toast notifications */
|
|
.ds-toast {
|
|
box-shadow: var(--shadow-lg);
|
|
}
|
|
```
|
|
|
|
### Dark Mode Shadows
|
|
|
|
Dark mode shadows are automatically adjusted through color-space calculations:
|
|
|
|
```css
|
|
:root.dark .ds-card {
|
|
box-shadow: var(--shadow-lg); /* Adapts to dark background */
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## Z-Index Tokens
|
|
|
|
Layering and stacking context management.
|
|
|
|
### Z-Index Scale
|
|
|
|
| Token | Value | Use Cases |
|
|
|-------|-------|-----------|
|
|
| `--z-toast` | `9999` | Toast notifications (highest) |
|
|
| `--z-modal` | `9998` | Modal backdrops |
|
|
| `--z-dropdown` | `1000` | Dropdown menus |
|
|
| `--z-sticky` | `100` | Sticky headers |
|
|
| `--z-base` | `1` | Default z-index |
|
|
|
|
### Z-Index Usage Examples
|
|
|
|
```css
|
|
/* Toast container */
|
|
.ds-toast-provider {
|
|
position: fixed;
|
|
z-index: var(--z-toast); /* 9999 - Always on top */
|
|
}
|
|
|
|
/* Modal backdrop */
|
|
.modal-backdrop {
|
|
position: fixed;
|
|
z-index: calc(var(--z-toast) - 1); /* 9998 */
|
|
}
|
|
|
|
/* Dropdown menu */
|
|
.dropdown {
|
|
position: absolute;
|
|
z-index: var(--z-dropdown); /* 1000 */
|
|
}
|
|
|
|
/* Sticky header */
|
|
header {
|
|
position: sticky;
|
|
z-index: var(--z-sticky); /* 100 */
|
|
}
|
|
|
|
/* Notification badge (overlay) */
|
|
.notification-badge {
|
|
position: absolute;
|
|
z-index: calc(var(--z-sticky) + 1);
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## Using Design Tokens
|
|
|
|
### In CSS
|
|
|
|
```css
|
|
/* Using tokens in stylesheets */
|
|
.my-component {
|
|
background: var(--primary);
|
|
color: var(--foreground);
|
|
padding: var(--space-4);
|
|
border-radius: var(--radius);
|
|
box-shadow: var(--shadow-md);
|
|
font-size: var(--text-base);
|
|
transition: all var(--duration-normal) var(--ease-default);
|
|
}
|
|
```
|
|
|
|
### In CSS-in-JS
|
|
|
|
```javascript
|
|
// Using tokens in styled components
|
|
const styles = `
|
|
background: var(--primary);
|
|
color: var(--foreground);
|
|
padding: var(--space-4);
|
|
`;
|
|
|
|
const component = document.createElement('div');
|
|
component.style.cssText = styles;
|
|
```
|
|
|
|
### In JavaScript
|
|
|
|
```javascript
|
|
// Reading token values
|
|
function getPrimaryColor() {
|
|
return getComputedStyle(document.documentElement)
|
|
.getPropertyValue('--primary')
|
|
.trim();
|
|
}
|
|
|
|
// Setting token values
|
|
function setPrimaryColor(color) {
|
|
document.documentElement.style.setProperty('--primary', color);
|
|
}
|
|
|
|
// Within Web Components
|
|
class MyComponent extends HTMLElement {
|
|
getCSSVariable(name) {
|
|
return getComputedStyle(this)
|
|
.getPropertyValue(name)
|
|
.trim();
|
|
}
|
|
|
|
setPrimaryColor(color) {
|
|
this.style.setProperty('--primary', color);
|
|
}
|
|
}
|
|
```
|
|
|
|
### As SCSS Variables
|
|
|
|
If using SCSS, you can reference tokens:
|
|
|
|
```scss
|
|
$primary: var(--primary);
|
|
$secondary: var(--secondary);
|
|
$space-4: var(--space-4);
|
|
$duration-normal: var(--duration-normal);
|
|
|
|
.my-button {
|
|
background: $primary;
|
|
padding: $space-4;
|
|
transition: all $duration-normal;
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## Theme Customization
|
|
|
|
### Changing Token Values
|
|
|
|
#### Global Customization
|
|
|
|
```css
|
|
/* Override tokens globally */
|
|
:root {
|
|
/* Custom colors */
|
|
--primary: #0066cc;
|
|
--secondary: #6366f1;
|
|
--success: #10b981;
|
|
|
|
/* Custom spacing */
|
|
--space-4: 1.25rem; /* Increase default spacing */
|
|
}
|
|
```
|
|
|
|
#### Dark Mode Customization
|
|
|
|
```css
|
|
/* Dark mode overrides */
|
|
:root.dark {
|
|
--primary: #3b82f6;
|
|
--secondary: #818cf8;
|
|
--success: #34d399;
|
|
|
|
--foreground: #f1f5f9;
|
|
--background: #0f172a;
|
|
--card: #1e293b;
|
|
--card-foreground: #e2e8f0;
|
|
}
|
|
```
|
|
|
|
#### Component-Specific Customization
|
|
|
|
```css
|
|
/* Override for specific component */
|
|
.my-custom-button {
|
|
--primary: #ff6b6b; /* Use custom primary for this button */
|
|
background: var(--primary);
|
|
}
|
|
```
|
|
|
|
### Switching Between Themes
|
|
|
|
```javascript
|
|
// Add dark mode class
|
|
function enableDarkMode() {
|
|
document.documentElement.classList.add('dark');
|
|
localStorage.setItem('theme', 'dark');
|
|
}
|
|
|
|
// Remove dark mode
|
|
function disableDarkMode() {
|
|
document.documentElement.classList.remove('dark');
|
|
localStorage.setItem('theme', 'light');
|
|
}
|
|
|
|
// Toggle dark mode
|
|
function toggleDarkMode() {
|
|
document.documentElement.classList.toggle('dark');
|
|
}
|
|
|
|
// Detect system preference
|
|
function detectSystemTheme() {
|
|
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
enableDarkMode();
|
|
}
|
|
}
|
|
|
|
// Apply saved preference on load
|
|
function loadSavedTheme() {
|
|
const saved = localStorage.getItem('theme');
|
|
if (saved === 'dark') {
|
|
enableDarkMode();
|
|
}
|
|
}
|
|
|
|
// Listen for system theme changes
|
|
window.matchMedia('(prefers-color-scheme: dark)')
|
|
.addEventListener('change', (e) => {
|
|
if (e.matches) {
|
|
enableDarkMode();
|
|
} else {
|
|
disableDarkMode();
|
|
}
|
|
});
|
|
```
|
|
|
|
### Token Export for Other Platforms
|
|
|
|
Design tokens can be exported for use in other design tools:
|
|
|
|
```json
|
|
{
|
|
"colors": {
|
|
"primary": "#3b82f6",
|
|
"secondary": "#6366f1",
|
|
"success": "#10b981"
|
|
},
|
|
"spacing": {
|
|
"4": "16px",
|
|
"6": "24px"
|
|
},
|
|
"typography": {
|
|
"base": "16px"
|
|
}
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## Token Validation
|
|
|
|
All components are validated to ensure they use design tokens instead of hardcoded values.
|
|
|
|
### Validation Rules
|
|
|
|
- ❌ **Hardcoded colors:** `background: #3b82f6;`
|
|
- ✅ **Token colors:** `background: var(--primary);`
|
|
- ❌ **Hardcoded spacing:** `padding: 16px;`
|
|
- ✅ **Token spacing:** `padding: var(--space-4);`
|
|
- ❌ **Hardcoded sizes:** `border-radius: 8px;`
|
|
- ✅ **Token sizes:** `border-radius: var(--radius);`
|
|
|
|
### Running Validation
|
|
|
|
```bash
|
|
npm run validate:tokens
|
|
```
|
|
|
|
---
|
|
|
|
## Migration Guide
|
|
|
|
### From v0.8.0 to v1.0.0
|
|
|
|
**Before (Hardcoded values):**
|
|
```css
|
|
.button {
|
|
background: #3b82f6;
|
|
padding: 16px 24px;
|
|
border-radius: 8px;
|
|
}
|
|
```
|
|
|
|
**After (Using tokens):**
|
|
```css
|
|
.button {
|
|
background: var(--primary);
|
|
padding: var(--space-3) var(--space-6);
|
|
border-radius: var(--radius);
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## Best Practices
|
|
|
|
1. **Always use tokens** - Never hardcode values
|
|
2. **Use semantic names** - Pick colors by semantic meaning (primary, success) not appearance (blue, green)
|
|
3. **Maintain contrast** - Ensure sufficient contrast for accessibility
|
|
4. **Test themes** - Always test in both light and dark modes
|
|
5. **Document changes** - Update this guide when adding tokens
|
|
6. **Version tokens** - Keep tokens in sync with component versions
|
|
|
|
---
|
|
|
|
## Summary Table
|
|
|
|
| Category | Count | Example |
|
|
|----------|-------|---------|
|
|
| Color tokens | 14 | `--primary`, `--success`, `--destructive` |
|
|
| Spacing tokens | 10 | `--space-1` through `--space-10` |
|
|
| Typography tokens | 5 | `--text-xs` through `--text-xl` |
|
|
| Radius tokens | 4 | `--radius`, `--radius-sm`, `--radius-full` |
|
|
| Duration tokens | 3 | `--duration-fast`, `--duration-normal`, `--duration-slow` |
|
|
| Shadow tokens | 4 | `--shadow-sm` through `--shadow-xl` |
|
|
| Z-index tokens | 5 | `--z-toast`, `--z-modal`, `--z-dropdown` |
|
|
| **TOTAL** | **45** | **All CSS variables** |
|
|
|
|
---
|
|
|
|
**For more information:** design-system@company.com
|