Tailwind CSS v4: CSS-First Configuration and 5x Faster Builds
Tailwind CSS v4 replaces tailwind.config.js with a CSS-first `@theme` directive and swaps PostCSS for Lightning CSS — here is everything that changed and how to migrate.
Mahmudul Haque Qudrati
CEO & ML Engineer
One AI engineering post, weekly
LLM benchmarks, prompt techniques, and token-cost breakdowns — not another AI news roundup.
Tailwind CSS v4 is not just an incremental update. It replaces the JavaScript configuration file with a CSS-first approach, swaps the PostCSS-based build pipeline for Lightning CSS, and introduces container queries, text shadows, and starting-style animations as first-class utilities.
CSS-First Configuration
The most visible change: no more tailwind.config.js. Configuration lives in your CSS file via the @theme directive:
/* Before (v3) — in tailwind.config.js */
/* module.exports = { theme: { extend: { colors: { brand: '#6366f1' } } } } */
/* After (v4) — directly in your CSS */
@import "tailwindcss";
@theme {
--color-brand: #6366f1;
--font-display: "Inter Variable", sans-serif;
--radius-card: 12px;
--spacing-18: 4.5rem;
}
Every @theme variable becomes a CSS custom property AND a Tailwind utility. After the above, you can write class="bg-brand text-brand" and class="rounded-card" immediately.
Team workspace
Ship faster with chat, meetings, and projects in one place — Zlyqor.
Lightning CSS Engine
Tailwind v4 ships with Lightning CSS (written in Rust) instead of PostCSS. Results:
- 5x faster full builds
- 100x faster incremental builds in watch mode
- No PostCSS config file required
- Vendor prefixes handled automatically
- CSS nesting supported natively (no plugin)
# v3 setup
pnpm add -D tailwindcss postcss autoprefixer
# + postcss.config.js required
# v4 setup — just Tailwind
pnpm add -D tailwindcss@next @tailwindcss/vite
# or for Next.js:
pnpm add -D tailwindcss@next @tailwindcss/postcss
Vite Plugin
For Vite-based projects, use the first-party Vite plugin instead of PostCSS:
// vite.config.ts
import tailwindcss from "@tailwindcss/vite";
export default {
plugins: [tailwindcss()],
};
Container Queries — Built In
Container queries no longer require the @tailwindcss/container-queries plugin:
<div class="@container">
<div class="@sm:flex-row flex-col flex gap-4">
<!-- switches to row layout when parent ≥ 24rem -->
</div>
</div>
Named containers:
<aside class="@container/sidebar">
<nav class="@lg/sidebar:block hidden">...</nav>
</aside>
New Utility Classes
Text shadow — finally built in:
<h1 class="text-shadow-lg text-shadow-black/25">Heading</h1>
Starting style for CSS entry animations without JavaScript:
<div class="starting:opacity-0 transition-opacity duration-300 opacity-100">
Fades in on first render
</div>
Migrating From v3
Most v3 projects need only a few changes:
# Run the official migration tool
npx @tailwindcss/upgrade
What the tool does:
- Converts
tailwind.config.js→@themeblock in your CSS - Replaces
@tailwind base/components/utilitieswith@import "tailwindcss" - Updates deprecated class names (
shadow-sm→shadow-xs, etc.) - Removes PostCSS config if you are using the Vite plugin
Manual check after migration: look for any plugins that used the JavaScript config API — those need to be rewritten for v4's CSS-based extension model.
References: Tailwind v4 blog · docs · upgrade guide

Mahmudul Haque Qudrati
CEO & ML Engineer
Visionary technologist, software engineer, and machine learning specialist. Founder and CEO of Pristren, directing engineering teams that ship production-grade AI/ML pipelines, mission-critical full-stack applications, and developer tooling. Creator of Zlyqor, the unified team workspace platform. Author of 540+ technical guides and benchmark research reports on large language models, agentic workflows, Model Context Protocol (MCP), and modern web stacks.
More from Mahmudul
Related Articles
How to Build with Codex: Avoiding the Logging Bug That Writes TBs to Local SSDs
A logging bug in Codex can write terabytes of logs to your local SSD. Here's how to detect, fix, and prevent it with practical steps and configuration changes.
How to Build with Claude Code – Everything you can configure that the docs don't tell you
Claude Code's docs cover basics, but the real power is in hidden configs. Learn how to customize prompts, manage costs, and integrate with your workflow.
How to Build an MCP Server in TypeScript (Step-by-Step)
Build your first MCP server in TypeScript with the official SDK — tools, stdio transport, and a Claude Code test loop in under an hour.
// discussion
Comments