Migrating to Tailwind CSS v4 CSS-First Architecture
Tailwind CSS v4 replaces the legacy JavaScript configuration file (tailwind.config.js) with a native, CSS-first architecture. In v4, design tokens and custom utility extensions are declared directly in your main stylesheet using standard CSS variables inside the @theme directive.
Key Syntax Changes
- CSS Variables: Colors like
theme.extend.colors.brand[500]become--color-brand-500: #22c55e;inside@theme. - Automatic Utilities: Declaring
--color-brand-500automatically createsbg-brand-500,text-brand-500,border-brand-500, andring-brand-500utility classes. - Zero Build Config: No plugins or custom postcss configuration files are required—simply import Tailwind via
@import "tailwindcss";.