Skip to main content
Craft UI is built with Tailwind CSS and uses a comprehensive theming system based on CSS variables. This approach provides flexibility and makes it easy to customize colors, spacing, typography, and more.

Overview

The theming system consists of three layers:
  1. CSS Variables - Semantic color tokens defined in your global stylesheet
  2. Tailwind Configuration - Extended with custom design tokens
  3. Component Classes - Applied using Tailwind utilities

CSS Variables

Craft UI uses CSS variables (custom properties) to define semantic color tokens that automatically adapt to light and dark modes.

Color System

All colors are defined using the OKLCH color space for perceptually uniform color manipulation:
globals.css

Available Color Tokens

Craft UI provides the following semantic color tokens:
  • background / foreground - Base colors for your application
  • primary / primary-foreground - Primary brand colors
  • secondary / secondary-foreground - Secondary accent colors
  • muted / muted-foreground - Muted backgrounds and text
  • accent / accent-foreground - Accent highlights
  • destructive / destructive-foreground - Error and danger states
  • border - Border colors
  • input - Input field backgrounds
  • ring - Focus ring colors
  • card / card-foreground - Card backgrounds
  • popover / popover-foreground - Popover backgrounds

Dark Mode

Dark mode is implemented using a .dark class that overrides the CSS variables:
globals.css
To enable dark mode, add the dark class to your root element:
Use the @custom-variant dark (&:is(.dark *)); directive in your CSS to create a custom dark mode variant that works with nested dark mode contexts.

Customizing Colors

1

Modify CSS Variables

Update the color values in your globals.css file to match your brand:
globals.css
2

Update Dark Mode

Don’t forget to update dark mode variants:
globals.css
3

Use Tailwind Classes

Components automatically pick up your custom colors:

Typography

Customize fonts using CSS variables:
globals.css
These are automatically mapped to Tailwind’s font utilities:

Border Radius

Adjust the default border radius for all components:
globals.css
The system provides calculated radius variants:
  • --radius-sm: calc(var(--radius) - 4px)
  • --radius-md: calc(var(--radius) - 2px)
  • --radius-lg: var(--radius)
  • --radius-xl: calc(var(--radius) + 4px)

Shadows

Customize shadow styles for depth and elevation:
globals.css

Spacing

Adjust the base spacing unit:
globals.css

Complete Theme Example

Here’s a complete example of a custom theme with a purple brand color:

Overriding Component Styles

All components accept a className prop that merges with default styles using the cn() utility:
The cn() utility is built with tailwind-merge and clsx, ensuring that Tailwind classes are properly merged and duplicates are resolved.
Later classes in the className prop will override earlier classes, allowing you to customize any aspect of a component’s appearance.

Per-Component Theming

For more granular control, use Tailwind’s arbitrary value syntax with CSS variables:
Or reference your theme variables directly:

Next Steps

  • Customization - Learn how to extend components with custom variants
  • Accessibility - Ensure your themed components remain accessible