tailwind css v4 migration
In the ground since Tue Sep 30 2025
Last watered inTue Sep 30 2025
Related Topics
Migrating from Tailwind CSS v3 to v4
Tailwind CSS v4 introduces a revolutionary architecture with significant performance improvements and a new CSS-first configuration approach. This guide documents the migration process from v3.4.1 to v4.0.
Why Migrate?
Performance Gains
Key Improvements
- CSS-first configuration: No more JavaScript config files
- Simplified imports: Single @import "tailwindcss" replaces three directives
- Modern architecture: Built for Safari 16.4+, Chrome 111+, Firefox 128+
- Better developer experience: Faster feedback loop during development
Migration Process
Automated Migration Tool
The easiest way to migrate is using the official upgrade tool:
What the Tool Handles
The automated migration tool handles most of the heavy lifting:
- Dependencies: Updates package.json with latest Tailwind v4
- CSS imports: Converts @tailwind directives to @import
- Configuration: Migrates JavaScript config to CSS variables
- PostCSS: Updates PostCSS configuration
Before and After
CSS Imports Migration
Before (v3):
After (v4):
Configuration Migration
Before (v3) - tailwind.config.ts:
After (v4) - Inside CSS:
PostCSS Configuration
Before (v3):
After (v4):
Custom Theme Migration
One of the most complex parts of migration involves custom themes. Here's how extensive custom color palettes are handled:
Color Palette Conversion
Before (v3):
After (v4):
Breakpoint Migration
Custom breakpoints are automatically converted:
Before (v3):
After (v4):
Custom Utilities
Utility classes using @layer need updating:
Before (v3):
After (v4):
Browser Compatibility
Supported browsers:
- Safari 16.4+
- Chrome 111+
- Firefox 128+
If you need to support older browsers, stick with v3.4 until your requirements change.
Potential Issues
Border Color Changes
v4 changes the default border color to currentcolor. The migration tool adds compatibility styles:
CSS Preprocessor Compatibility
Testing After Migration
After migration, thoroughly test:
- Development server: Ensure yarn dev starts without errors
- Build process: Verify yarn build completes successfully
- Visual testing: Check all pages for layout regressions
- Custom utilities: Verify all custom classes still work
- Performance: Measure build time improvements
Results
After successful migration, you should see:
- Dramatically faster builds: Especially noticeable in development
- Cleaner configuration: CSS-based theme configuration
- Simplified setup: Single import statement
- Future-ready codebase: Built on modern web standards
The migration to Tailwind CSS v4 represents a significant architectural shift that delivers substantial performance benefits while maintaining the utility-first approach that makes Tailwind powerful.