Page Title
Page content goes here...
# 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-strong` is more descriptive than `bg-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: 1. **Semantic Colors** - Intent-based colors (brand, neutral, positive, negative, etc.) 2. **Layer Tokens** - Elevation and surface hierarchy 3. **Overlay Tokens** - Background overlays for dialogs and modals 4. **Typography Tokens** - Text size and style scales 5. **Interaction States** - Hover and active states --- ## Semantic Colors ### The 9 Intents Our design system defines 9 different semantic intents, each representing a distinct purpose: 1. **Neutral** - Default elements without strong emphasis (grays) 2. **Brand** - Brand-specific elements (primary color) 3. **Inverse** - Inverted neutral scale for contrast 4. **Positive** - Positive actions, confirmations, success states (green) 5. **Warning** - Alerts and cautionary indicators (orange/yellow) 6. **Negative** - Errors and destructive actions (red) 7. **Informative** - Informational elements (blue) 8. **Highlight** - High prominent elements (accent colors) 9. **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 ```css /* Neutral backgrounds */ bg-neutral-strong /* High contrast neutral */ bg-neutral-mid /* Standard neutral */ bg-neutral-subtle /* Subtle neutral */ bg-neutral-low /* Very light neutral */ /* Brand backgrounds */ bg-brand-strong /* Strong brand color */ bg-brand-mid /* Primary brand color */ bg-brand-subtle /* Subtle brand tint */ bg-brand-low /* Very light brand tint */ /* Status backgrounds */ bg-positive-mid /* Success/confirmation green */ bg-negative-mid /* Error/danger red */ bg-warning-mid /* Warning orange/yellow */ bg-info-mid /* Information blue */ bg-highlight-mid /* Accent/emphasis color */ ``` ### Text Classes ```css /* Neutral text - for body content */ text-neutral-strong /* Headings and primary text */ text-neutral-mid /* Body text */ text-neutral-subtle /* Secondary text */ text-neutral-low /* Tertiary/helper text */ /* Brand text */ text-brand-strong text-brand-mid text-brand-subtle /* Status text */ text-positive-mid /* Success messages */ text-negative-mid /* Error messages */ text-warning-mid /* Warning messages */ text-info-mid /* Info messages */ /* Inverse text (on dark backgrounds) */ text-inverse-strong text-inverse-mid text-inverse-subtle text-inverse-low /* Disabled state */ text-disabled ``` ### On-Color Text (Contrast Text) For text that appears on colored backgrounds with proper contrast: ```css /* Text on brand backgrounds */ text-onbrand-strong text-onbrand-mid text-onbrand-subtle text-onbrand-low /* Text on positive/success backgrounds */ text-onpositive-strong text-onpositive-mid text-onpositive-subtle text-onpositive-low /* Text on negative/error backgrounds */ text-onnegative-strong text-onnegative-mid text-onnegative-subtle text-onnegative-low /* Text on warning backgrounds */ text-onwarning-strong text-onwarning-mid text-onwarning-subtle text-onwarning-low /* Text on info backgrounds */ text-oninfo-strong text-oninfo-mid text-oninfo-subtle text-oninfo-low ``` ### Border Classes ```css /* Neutral borders */ border-neutral-strong border-neutral-mid border-neutral-subtle border-neutral-low /* Brand borders */ border-brand-strong border-brand-mid border-brand-subtle /* Status borders */ border-positive-mid border-negative-mid border-warning-mid border-info-mid /* Disabled state */ border-disabled ``` ### Interaction States Interactive elements support hover and active states: ```css /* Background interactions */ bg-neutral-subtle-hover bg-neutral-subtle-active bg-brand-mid-hover bg-brand-mid-active /* Text interactions */ text-brand-mid-hover text-brand-mid-active /* Border interactions */ border-neutral-subtle-hover border-brand-mid-hover ``` --- ## 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 ```css bg-layer-below /* Lowest background layer (page background) */ bg-layer-surface /* Main content surface (cards, panels) */ bg-layer-raised /* Elevated content (floating cards) */ bg-layer-popover /* Popover/dropdown backgrounds */ bg-layer-dialog /* Modal/dialog backgrounds */ bg-layer-control /* Form control backgrounds (inputs) */ ``` ### 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: ```css overlay-strong /* High opacity overlay (75-90%) */ overlay-mid /* Medium opacity overlay (50-65%) */ overlay-subtle /* Low opacity overlay (25-40%) */ overlay-low /* Very low opacity overlay (10-20%) */ ``` ### Overlay Usage ```jsx {/* Modal backdrop */}
Card content with proper semantic colors.
Success! Your changes have been saved.
Error! Something went wrong.
Warning! This action cannot be undone.
Info: New features are available.
Page content goes here...
Are you sure you want to proceed?
Body paragraph
Helper text