Core Concepts

Understand design tokens, theme structure, and how Turbo Themes works under the hood.

Core Concepts

This guide explains the fundamental concepts behind Turbo Themes and how it works.

Design Tokens

Design tokens are the foundation of Turbo Themes. They are CSS custom properties (variables) that represent your design decisions as reusable values.

/* Example design tokens */
:root {
  --turbo-bg-base: #1e1e2e;
  --turbo-text-primary: #cdd6f4;
  --turbo-brand-primary: #89b4fa;
}

Why Use Design Tokens?

  1. Consistency - Same color values everywhere
  2. Maintainability - Change once, update everywhere
  3. Theming - Swap values to change the entire look
  4. Semantic meaning - Names describe purpose, not appearance

Token Categories

Turbo Themes organizes tokens into semantic categories:

Backgrounds (--turbo-bg-*)

TokenPurpose
--turbo-bg-baseMain page background
--turbo-bg-surfaceCards, modals, elevated surfaces
--turbo-bg-overlayOverlays, dropdowns, tooltips

Text (--turbo-text-*)

TokenPurpose
--turbo-text-primaryMain body text
--turbo-text-secondaryMuted, less important text
--turbo-text-inverseText on colored backgrounds

Brand (--turbo-brand-*)

TokenPurpose
--turbo-brand-primaryPrimary accent color, CTAs

State (--turbo-state-*)

TokenPurpose
--turbo-state-successSuccess messages, confirmations
--turbo-state-warningWarnings, cautions
--turbo-state-dangerErrors, destructive actions
--turbo-state-infoInformational messages

Border (--turbo-border-*)

TokenPurpose
--turbo-border-defaultStandard border color

Syntax (--turbo-syntax-*)

Tokens for code syntax highlighting:

TokenPurpose
--turbo-syntax-commentCode comments
--turbo-syntax-keywordLanguage keywords
--turbo-syntax-stringString literals
--turbo-syntax-numberNumbers
--turbo-syntax-functionFunction names
--turbo-syntax-typeType annotations

Theme Structure

Each theme defines values for all tokens. When you load a different theme CSS file, all the token values change, and your UI updates automatically.

/* catppuccin-mocha.css */
:root {
  --turbo-bg-base: #1e1e2e;
  --turbo-text-primary: #cdd6f4;
  /* ... */
}

/* dracula.css */
:root {
  --turbo-bg-base: #282a36;
  --turbo-text-primary: #f8f8f2;
  /* ... */
}

File Structure

The Turbo Themes package is organized as follows:

turbo-themes/
β”œβ”€β”€ css/
β”‚   β”œβ”€β”€ turbo-core.css      # Token variable definitions
β”‚   β”œβ”€β”€ turbo-base.css      # Base semantic styles
β”‚   β”œβ”€β”€ turbo-syntax.css    # Syntax highlighting
β”‚   β”œβ”€β”€ themes/
β”‚   β”‚   └── turbo/
β”‚   β”‚       β”œβ”€β”€ catppuccin-mocha.css
β”‚   β”‚       β”œβ”€β”€ catppuccin-latte.css
β”‚   β”‚       β”œβ”€β”€ dracula.css
β”‚   β”‚       └── ...
β”‚   └── adapters/
β”‚       β”œβ”€β”€ bulma.css       # Bulma framework adapter
β”‚       └── tailwind.css    # Tailwind preset

How Theme Switching Works

Theme switching is simple because all your CSS uses the same token names:

  1. Your CSS references tokens: background: var(--turbo-bg-surface)
  2. The browser resolves the current value of --turbo-bg-surface
  3. When you load a different theme file, the value changes
  4. The browser automatically re-renders with the new value

This means:

  • No JavaScript required for styling
  • No re-rendering of components
  • Instant theme changes
  • Works with any framework

Framework Adapters

Turbo Themes provides adapters that map tokens to framework-specific variables:

Bulma Adapter

Maps Turbo tokens to Bulma’s CSS variables so Bulma components use your theme colors automatically.

Tailwind Preset

Extends Tailwind’s color palette with Turbo token references, enabling classes like bg-turbo-surface and text-turbo-primary.

Next Steps

Now that you understand the concepts: