@theme
The Tailwind CSS version 4 directive where you declare design tokens in CSS, which become both CSS variables and utility classes.
In more detail
Writing @theme { --color-brand: #2563eb; } creates a --color-brand custom property on :root and utilities such as bg-brand and text-brand that use it. The token's namespace, such as --color- or --spacing-, decides which utilities are generated.
Example
@theme { --color-accent: oklch(65% 0.22 140); } generates bg-accent and text-accent.Related terms
- Tailwind CSS — A CSS framework made of small single-purpose utility classes, such as bg-blue-600 or px-4, that you combine in markup.
- utility class — A CSS class that does one small job, such as p-4 for padding or text-white for text colour.
- CSS custom property — A value you name yourself in CSS, such as --color-primary: #2563eb, and use elsewhere with var(--color-primary).
Taught in
- Tailwind CSS v4 Engine: CSS Variables & Theme Extensions — Design Systems & Component Engineering