Tailwind CSS v4 Theme Integration

Published Updated
Instructions for declaring design tokens in Tailwind v4's root stylesheet and using them in components.

Tailwind CSS v4 introduces theme configuration directly in CSS using the @theme directive, bypassing the legacy tailwind.config.js configuration.

Ensure all semantic colors and sizing values from the design system are mapped in this block, avoiding inline arbitrary values (e.g. bg-[#1a1a1a]).

index.css (css)
@import "tailwindcss";

@theme {
  --color-brand-accent: #0066cc;
  --color-brand-hover: #0052a3;
  --color-surface-base: #ffffff;
  --color-surface-muted: #f5f5f7;
  
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  
  --radius-sm: 4px;
  --radius-md: 8px;
}
Tailwind CSS v4 theme variables declaration