Design Tokens
Understanding Frontfriend's semantic token system for consistent design
Design Tokens
Frontfriend uses a semantic token system that provides meaningful, intent-based design tokens instead of traditional color-based utilities. This approach ensures consistency, scalability, and automatic theming support.
Why Semantic Tokens?
A semantic token is an abstraction layer that helps define design decisions in a meaningful way rather than relying on raw, primitive values. Instead of using direct values like #ff0000 for red or 16px for padding, semantic tokens assign intent-driven names that reflect their purpose in the UI.
Key Benefits
- Meaningful Names -
bg-brand-strongis more descriptive thanbg-blue-500 - Automatic Theming - Light and dark modes work automatically
- Design Consistency - Tokens come directly from your Figma design system
- Scalability - Changes in design propagate across all applications
- Maintainability - Update tokens centrally, not in every component
Important: Do NOT use traditional Tailwind color classes like bg-blue-500, text-red-600, or border-green-400. Always use semantic token classes instead.
Token System Overview
Frontfriend's token system is organized into several categories:
- Semantic Colors - Intent-based colors (brand, neutral, positive, negative, etc.)
- Layer Tokens - Elevation and surface hierarchy
- Overlay Tokens - Background overlays for dialogs and modals
- Typography Tokens - Text size and style scales
- Interaction States - Hover and active states
Semantic Colors
The 9 Intents
Our design system defines 9 different semantic intents, each representing a distinct purpose:
- Neutral - Default elements without strong emphasis (grays)
- Brand - Brand-specific elements (primary color)
- Inverse - Inverted neutral scale for contrast
- Positive - Positive actions, confirmations, success states (green)
- Warning - Alerts and cautionary indicators (orange/yellow)
- Negative - Errors and destructive actions (red)
- Informative - Informational elements (blue)
- Highlight - High prominent elements (accent colors)
- Interactive - Default interactive element colors
Intensity Levels
Each semantic color has four intensity levels for creating visual hierarchy:
strong- Highest contrast/saturation (primary emphasis)mid- Medium contrast/saturation (standard use)subtle- Low contrast/saturation (secondary elements)low- Lowest contrast/saturation (backgrounds)
Background Classes
Text Classes
On-Color Text (Contrast Text)
For text that appears on colored backgrounds with proper contrast:
Border Classes
Interaction States
Interactive elements support hover and active states:
Layer Tokens
Layer tokens define the elevation hierarchy of UI surfaces. They determine how elements visually stack and interact with each other, creating depth and organization.
The 6 Layer Levels
Layer Usage Guide
| Layer | Purpose | Example Use Cases |
|---|---|---|
layer-below | Page background | App background, body |
layer-surface | Content containers | Main cards, sections |
layer-raised | Elevated elements | Featured cards, hovering menus |
layer-popover | Floating UI | Dropdowns, tooltips, popovers |
layer-dialog | Modals | Dialogs, sheets, overlays |
layer-control | Form inputs | Text inputs, selects, textareas |
Overlay Tokens
Overlay tokens are used for semi-transparent backgrounds, typically for dialogs, modals, or drawer overlays:
Overlay Usage
Typography Tokens
Typography tokens provide a consistent text size scale across your application. Frontfriend uses Tailwind's font-size utilities for typography.
Text Size Classes
These work with standard Tailwind typography utilities and integrate seamlessly with semantic color tokens.
Common Usage Patterns
Card Component
Button Components
Form Input
Alert Messages
Page Layout
Modal Dialog
Dark Mode Support
One of the key advantages of semantic tokens is automatic dark mode support. The same semantic classes work in both light and dark modes without any additional code:
The token values automatically switch based on the user's theme preference, ensuring proper contrast and readability in all scenarios.
Icon Classes
SVG Fill Colors
For coloring SVG icons using the fill attribute:
Icon Text Colors
For icon fonts or text-based icons:
Icon Usage
Migration from Traditional Tailwind
When converting existing code from traditional Tailwind to Frontfriend semantic tokens:
| Traditional Tailwind | Frontfriend Semantic | Purpose |
|---|---|---|
bg-white | bg-layer-surface | Main surface background |
bg-gray-50 | bg-neutral-low | Very subtle background |
bg-gray-100 | bg-neutral-subtle | Subtle background |
bg-gray-900 | bg-neutral-strong | Strong neutral background |
text-gray-900 | text-neutral-strong | Primary text/headings |
text-gray-600 | text-neutral-mid | Body text |
text-gray-400 | text-neutral-subtle | Secondary text |
bg-blue-500 | bg-brand-mid | Primary brand color |
text-blue-600 | text-brand-mid | Brand text |
border-gray-200 | border-neutral-subtle | Subtle borders |
bg-red-50 | bg-negative-low | Error background |
text-red-600 | text-negative-mid | Error text |
bg-green-50 | bg-positive-low | Success background |
text-green-600 | text-positive-mid | Success text |
bg-yellow-50 | bg-warning-low | Warning background |
text-yellow-600 | text-warning-mid | Warning text |
Best Practices
1. Always Use Semantic Classes
Use semantic tokens that describe intent, not appearance:
2. Choose Appropriate Intensity
Select the right intensity level for visual hierarchy:
3. Use Layer Tokens for Elevation
Build proper elevation hierarchy with layer tokens:
4. Consider Interaction States
Always provide hover and active states for interactive elements:
5. Use On-Color Text for Contrast
When placing text on colored backgrounds, use on-color variants with appropriate intensity:
6. Never Hardcode Colors
All colors should come from the design system:
Next Steps
- CLI Reference - Learn all available CLI commands
- React Setup - Set up tokens in React projects
- Vue Setup - Set up tokens in Vue projects
- Troubleshooting - Common issues and solutions