Tailwind CSS v4 Migration: New Features Guide 2026
Migrate to Tailwind CSS v4 with confidence. Breaking changes, new canonical classes, CSS variables, and performance improvements explained.
Build performance improvement over v3
Mechanical migration handled by upgrade CLI
Cold build time reduction (Lightning CSS)
tailwind.config.js files needed in v4
Key Takeaways
Tailwind CSS v4 is a ground-up architectural rethink — not an incremental update. The configuration model, plugin API, build pipeline, and dozens of utility class names changed. For teams running v3 in production, migration requires a structured approach: understand what changed, run the automated upgrade tool, verify output, and address plugin compatibility manually.
This guide covers every dimension of the v3 to v4 migration with exact before/after code examples, a complete class rename reference, and a step-by-step migration sequence tested on production Next.js and Vite projects.
1. What Changed in v4
Tailwind v4 introduces five architectural changes that collectively improve DX, performance, and CSS standards alignment. Understanding these changes at a conceptual level before running the migration tool prevents confusion when reviewing diffs.
2. Canonical Class Renames
The utility rename table covers every deprecated class and its v4 canonical replacement. The @tailwindcss/upgrade CLI handles all of these automatically. The table is provided for manual review and to understand the naming rationale.
| v3 (Legacy — DO NOT USE) | v4 Canonical | Category |
|---|---|---|
| bg-gradient-to-t | bg-linear-to-t | Gradients |
| bg-gradient-to-br | bg-linear-to-br | Gradients |
| flex-shrink-0 | shrink-0 | Flexbox |
| flex-shrink | shrink | Flexbox |
| flex-grow | grow | Flexbox |
| flex-grow-0 | grow-0 | Flexbox |
| bg-[size:200%] | bg-size-[200%] | Background |
| [mask-image:...] | mask-[...] | Masking |
| aspect-[16/9] | aspect-video | Aspect Ratio |
| overflow-ellipsis | text-ellipsis | Typography |
| decoration-slice | box-decoration-slice | Typography |
3. CSS Variables System
The CSS variables system is v4's most powerful new capability. Every design token defined in @theme is automatically exposed as a CSS custom property and generates corresponding utilities. This eliminates the disconnect between Tailwind utilities and raw CSS.
Defining Tokens in @theme
globals.css
@import "tailwindcss";
@theme {
/* Colors — auto-generates: bg-brand, text-brand, border-brand */
--color-brand: #4f46e5;
--color-brand-light: #818cf8;
/* Typography */
--font-sans: "Geist", "Inter", system-ui, sans-serif;
--font-mono: "Geist Mono", monospace;
/* Spacing — extends default scale */
--spacing-18: 4.5rem;
--spacing-22: 5.5rem;
/* Breakpoints */
--breakpoint-3xl: 1920px;
}
/* Use tokens in custom CSS */
.custom-component {
background: var(--color-brand);
font-family: var(--font-sans);
}Using Tokens in JSX
{/* Generated utilities from @theme tokens */}
<div className="bg-brand text-white">Brand background</div>
<span className="text-brand-light">Light brand text</span>
{/* Arbitrary values using CSS custom properties */}
<div className="bg-[--color-brand] p-18">Custom spacing token</div>
{/* Inline style using CSS variable */}
<div style={{ "--accent": "var(--color-brand)" }}>...</div>4. Configuration Migration
The configuration migration converts your tailwind.config.js theme extensions into CSS @theme blocks. The mapping is direct — every key in your theme.extend becomes a CSS custom property under the corresponding namespace.
v3: tailwind.config.js
module.exports = {
theme: {
extend: {
colors: {
brand: "#4f46e5",
"brand-light": "#818cf8",
},
fontFamily: {
sans: ["Geist", "Inter"],
},
spacing: {
18: "4.5rem",
},
},
},
darkMode: "class",
};v4: globals.css
@import "tailwindcss";
@theme {
--color-brand: #4f46e5;
--color-brand-light: #818cf8;
--font-sans: "Geist", "Inter",
system-ui, sans-serif;
--spacing-18: 4.5rem;
}
/* Class-based dark mode */
@variant dark (&:is(.dark *));@variant dark (&:is(.dark *)); to your CSS file. This replicates the class-based dark mode behavior and ensures dark: utility variants target the .dark class on your html element.5. Plugin Compatibility
Plugin compatibility is the primary source of migration complexity. Check each plugin in your plugins array against the table below before migrating.
| Plugin | v4 Status | Notes |
|---|---|---|
| @tailwindcss/typography | Compatible | v0.5.10+ fully supports v4 via @plugin |
| @tailwindcss/forms | Compatible | v0.5.7+ supports v4 |
| @tailwindcss/aspect-ratio | Deprecated | Built into v4 core — remove plugin |
| tailwindcss-animate | Compatible | Used by shadcn/ui — v4 version available |
| shadcn/ui | Compatible | Full v4 support via canary channel (2024) |
| Custom JS plugins | Manual Migration | Rewrite as @layer utilities or @plugin CSS |
6. Performance Gains
The switch to Lightning CSS delivers measurable build performance improvements that directly impact development speed and CI/CD pipeline costs.
| Scenario | v3 Build Time | v4 Build Time | Improvement |
|---|---|---|---|
| Cold build (1,000 classes) | 1,200ms | 480ms | 2.5x faster |
| Incremental rebuild | 280ms | 12ms | 23x faster |
| Large design system (5,000+ classes) | 8,400ms | 1,200ms | 7x faster |
| Production CSS bundle size | Baseline | ~15% smaller | Better minification |
For SEO implications of CSS performance improvements, see our guide on SEO optimization services. Faster CSS rendering contributes to LCP improvements that affect search rankings.
7. Step-by-Step Migration
Follow this sequence in order. Do not skip steps — particularly the branch creation and backup steps. The migration involves automated file modifications across your entire codebase.
Create a dedicated migration branch
git checkout -b feat/tailwind-v4-migration
Never run the upgrade tool on main. Create a clean branch for full diff review.
Install v4 and run the upgrade tool
npm install tailwindcss@latest @tailwindcss/vite npx @tailwindcss/upgrade
The upgrade CLI installs v4, updates your PostCSS/Vite config, renames classes, and converts tailwind.config.js to CSS @theme blocks.
Update your CSS entrypoint
@import "tailwindcss"; /* Remove: @tailwind base; @tailwind components; @tailwind utilities; */
The single @import "tailwindcss"; line replaces the three @tailwind directives. Place your @theme block immediately after.
Review and fix plugin compatibility
# Check each plugin in your config npm update @tailwindcss/typography @tailwindcss/forms
Update first-party Tailwind plugins. For custom plugins using addUtilities(), rewrite as @layer utilities CSS.
Fix dark mode if using class strategy
@variant dark (&:is(.dark *));
Add this @variant directive to your CSS file if you use the class dark: strategy. Place it after your @theme block.
Run build and fix remaining issues
npm run build 2>&1 | grep -E 'error|warn'
Address any build warnings. Common issues: missed class renames in string literals (CSS modules, template strings), custom CSS using theme() function calls that need updating.
Test across browsers and dark mode
# Test in Chrome, Firefox, Safari # Test light + dark mode toggle # Verify responsive breakpoints
Pay particular attention to gradient utilities, flexbox helpers, and any custom component using arbitrary values — these have the highest failure rate in migration.
For React Server Components and architecture patterns that work with Tailwind v4, see our React Server Components Production Pattern Guide. RSC architecture aligns naturally with v4's CSS-native approach.
Migrating with Confidence
The Tailwind CSS v4 migration is less disruptive than major framework upgrades — the core utility model is unchanged, and the automated upgrade tool handles the mechanical work. The areas requiring manual attention are plugin compatibility and dark mode configuration for projects that used the class strategy.
After migration, you gain substantially faster builds, CSS-native design token access, and a configuration system that does not require Node.js to understand. For greenfield projects, start directly on v4 — the CSS-first configuration is simpler to maintain than JavaScript config objects.
Need a Web Development Partner?
Our development team builds production Next.js applications with Tailwind CSS v4, React Server Components, and modern performance optimization built in from day one.
Frequently Asked Questions
Related Development Guides
Continue exploring modern web development tools and techniques.