Design Tokens
Design tokens are the foundation of Stride’s theming system. They define colors, typography, spacing, and other design attributes as reusable values that cascade through the entire design system.Token Architecture
Stride uses a two-tier token system:- Core Tokens - Raw color values organized by palette (primary, neutral, success, etc.)
- Semantic Tokens - Contextual mappings that reference core tokens for specific use cases
CSS Variable Naming Convention
All tokens are exposed as CSS custom properties (variables) with a consistent naming pattern:Core Token Categories
Core tokens define the raw color palette. Fromsrc/app/brands.css, here are examples from the Stride brand:
Primary Colors
Brand identity colors used for primary actions, links, and focus states.Neutral Colors
Grays and neutrals used for text, borders, and backgrounds.- 0, 50, 100: Backgrounds, subtle surfaces
- 200, 300: Borders, dividers
- 400, 500: Disabled states, tertiary text
- 600, 700: Secondary text, icons
- 800, 900, 950: Primary text, dark surfaces
Status Colors
Colors for success, warning, and error states.- 50: Background for success/warning/error alerts
- 100: Subtle background variant
- 500: Base color for icons, borders
- 600: Hover state
- 700: Text color on light backgrounds
Semantic Token Categories
Semantic tokens map core tokens to specific use cases. They automatically adapt to light/dark mode and brand changes.Text Tokens
Fromsrc/app/brands.css:59:
Background Tokens
Fromsrc/app/brands.css:67:
Interactive Tokens
Tokens for buttons and interactive elements, fromsrc/app/brands.css:81:
- Base color
- Hover (slightly darker)
- Active (darkest - pressed state)
- Disabled (muted)
Border Tokens
Fromsrc/app/brands.css:75:
Status Tokens
Semantic tokens for status indicators, fromsrc/app/brands.css:97:
Typography Tokens
Font families and weights, fromsrc/app/brands.css:54:
src/lib/brands.ts:126):
Layout Tokens
Spacing, border radius, shadows, and transitions. TypeScript interface (fromsrc/lib/brands.ts:136):
src/app/brands.css:334):
src/app/brands.css:222):
Defining Custom Tokens
Add brand-specific CSS variables that aren’t part of the standard token system:Semantic Mapping Patterns
Best practices for mapping semantic tokens to core tokens.Pattern 1: Direct Reference
Most common - reference core tokens directly:Pattern 2: Color Mixing
Create variations using CSS color-mix:Pattern 3: Token Chaining
Reference other semantic tokens:Pattern 4: Hardcoded Values
Use when a specific value is needed regardless of core palette:Dark Mode Support
Semantic tokens automatically adapt to dark mode. Fromsrc/app/brands.css:588:
--text-primary will adapt to both light and dark modes without any changes.
Token Resolution Order
When applying a dynamic brand, tokens are resolved in this order:- Custom tokens - Applied first (highest priority)
- Layout tokens - Applied next
- Typography tokens - Then typography
- Semantic tokens - Then semantic mappings
- Core tokens - Base color definitions
- Fallback brand - Used for any undefined tokens
src/lib/brands.ts:394, the token application logic:
TypeScript Types
Complete type definitions fromsrc/lib/brands.ts:
Best Practices
-
Always use semantic tokens in components
-
Provide complete interactive state tokens
-
Use color-mix for variations
-
Leverage fallback for missing tokens
-
Use descriptive custom token names
Next Steps
- Creating Brands - Learn to create custom brands
- Theme Switching - Implement runtime brand switching