Explore the new CSS-first configuration, Lightning CSS engine, and native CSS variable integration in Tailwind v4.

The Article
The full story, in the order it happened.
Tailwind CSS v4 introduces the biggest architectural leap in the framework's history. By transitioning away from JavaScript-heavy configuration files (tailwind.config.js) toward a pure CSS-first model, developers gain unprecedented build speed and cleaner stylesheet integration.
1. What Changed in Tailwind v4?
In previous versions, configuring colors, fonts, and plugins required writing JavaScript objects inside a config file. With Tailwind v4, everything lives directly inside your CSS using native directives:
@import "tailwindcss";
@theme inline {
--color-primary: #7f00fd;
--font-heading: 'Syne', sans-serif;
}
The new engine is powered by Rust-based compiler tooling, compiling production builds up to 10x faster than v3.
2. Native CSS Variables & Color Functions
Tailwind v4 is built natively around modern CSS variables. Instead of generating hundreds of opaque hex codes, utilities bind directly to custom properties:
- Seamless dark mode switching without duplicate classes.
- First-class support for
oklch()color gamuts offering vibrant displays on modern P3 screens. - Zero-runtime overhead for dynamic theme customizations.
3. Best Practices for Upgrading
When upgrading your Next.js projects:
- Replace your imports with
@import "tailwindcss";. - Move custom font variables to
@theme. - Take advantage of
@custom-variantto map dark mode directly to system preferences.

Tahmid Hasan
Web developer and UI designer building fast, accessible interfaces — and writing down what he learns along the way.
ABOUT ME