This is a step by step guide on how to migrate from Tailwind CSS 3 to Tailwind CSS 4 with shadcn/ui
Tailwind CSS 4 represents a complete rewrite of the framework with massive performance improvements, a CSS-first configuration system, and full support for modern browser features. If you're using shadcn/ui components, this guide will walk you through the migration process based on the official documentation.
What's New in Tailwind CSS 4
Tailwind CSS v4.0 is a ground-up rewrite with a new high-performance engine that makes full builds over 3.5x faster and incremental builds over 8x faster. Incremental builds that don't need to compile new CSS are over 100x faster and complete in microseconds.
Key changes include:
CSS-first configuration: Configuration now lives in CSS using @import and @theme instead of JavaScript
Automatic content detection: No more configuring the content array - Tailwind automatically discovers your template files
Built-in imports: Native @import support without needing PostCSS plugins
Modern CSS features: Built on cascade layers, @property, and color-mix()
Simplified dependencies: Fewer dependencies and zero configuration needed
First-party Vite plugin: Tight integration for maximum performance
Prerequisites
Important: Tailwind CSS v4.0 is designed for Safari 16.4+, Chrome 111+, and Firefox 128+. If you need to support older browsers, stick with v3.4 until your browser support requirements change.
Before migrating, ensure you have:
Node.js 20 or higher (required for the upgrade tool)
A project using Tailwind CSS 3.x and shadcn/ui
Modern browser support requirements
Your project committed to version control
Step 1: Use the Official Upgrade Tool
Tailwind provides an automated upgrade tool that handles most of the migration process including updating dependencies, migrating configuration to CSS, and updating template files.
Run the upgrade tool:
npx @tailwindcss/upgrade
Important: Run the upgrade tool in a new branch, then carefully review the diff and test your project in the browser to make sure all changes look correct.
Step 2: Update CSS Import Syntax
The biggest change is how you import Tailwind. In v4 you import Tailwind using a regular CSS @import statement, not using the @tailwind directives you used in v3.
The upgrade tool will migrate your CSS variables, but you need to optimize them for easier use. Here's the shadcn/ui-specific approach:
The codemod will migrate your CSS variables as references under the @theme directive, but to make it easier to work with colors and other variables, you'll need to move the hsl wrappers and use @theme inline.
Tailwind v4 and React 19 remove the need for forwardRef in components. You can use the remove-forward-ref codemod to migrate your forwardRef to props or manually update the primitives.
Note the addition of data-slot attribute for styling purposes.
Step 10: Update Animation Plugin
shadcn/ui has deprecated tailwindcss-animate in favor of tw-animate-css.
Remove tailwindcss-animate from your dependencies
Install tw-animate-css:
npm install -D tw-animate-css
Update your CSS file:
/* Before */@plugin 'tailwindcss-animate';/* After */@import "tw-animate-css";
Renamed Utilities
Tailwind v4 renamed several utilities to make them more consistent and predictable. Here are all the changes:
v3
v4
shadow-sm
shadow-xs
shadow
shadow-sm
drop-shadow-sm
drop-shadow-xs
drop-shadow
drop-shadow-sm
blur-sm
blur-xs
blur
blur-sm
backdrop-blur-sm
backdrop-blur-xs
backdrop-blur
backdrop-blur-sm
rounded-sm
rounded-xs
rounded
rounded-sm
outline-none
outline-hidden
ring
ring-3
Updated shadow, radius, and blur scales: The "bare" versions still work for backward compatibility, but the <utility>-sm utilities will look different unless updated to their respective <utility>-xs versions.
Renamed outline utility: The outline-none utility didn't actually set outline-style: none - it set an invisible outline for accessibility. It's now renamed to outline-hidden, and a new outline-none utility actually sets outline-style: none.
Default ring width change: The ring utility now adds a 1px ring instead of 3px to be consistent with borders and outlines. Replace ring with ring-3 to maintain the old behavior.
Removed Deprecated Utilities
Tailwind v4 removes utilities that were deprecated in v3 and have been undocumented for several years. Here's the complete list:
Deprecated
Replacement
bg-opacity-*
Use opacity modifiers like bg-black/50
text-opacity-*
Use opacity modifiers like text-black/50
border-opacity-*
Use opacity modifiers like border-black/50
divide-opacity-*
Use opacity modifiers like divide-black/50
ring-opacity-*
Use opacity modifiers like ring-black/50
placeholder-opacity-*
Use opacity modifiers like placeholder-black/50
flex-shrink-*
shrink-*
flex-grow-*
grow-*
overflow-ellipsis
text-ellipsis
decoration-slice
box-decoration-slice
decoration-clone
box-decoration-clone
The upgrade tool should handle most of these automatically.
Automatic Content Detection
One of the best improvements: Tailwind v4 came up with a bunch of heuristics for detecting all of your template files automatically so you don't have to configure the content array at all. It automatically ignores anything in your .gitignore file and all binary extensions.
Browser compatibility: Test in your target browsers
Performance Benefits
Tailwind CSS v4.0 is a ground-up rewrite optimized for speed. Based on benchmarks against real projects, you should see:
Full rebuilds: Over 3.5x faster (378ms → 100ms in official benchmarks)
Incremental rebuilds with new CSS: Over 8x faster (44ms → 5ms)
Incremental rebuilds with no new CSS: Over 100x faster, completing in microseconds (35ms → 192µs = 182x improvement)
The most impressive improvement is on incremental builds that don't need to compile new CSS. These builds complete in microseconds because you're reusing classes you've already used before, like flex, col-span-2, or font-bold.
Additional benefits include:
Smaller CSS output
Faster hot module replacement
Better overall developer experience with near-instantaneous feedback
Using shadcn/ui CLI After Migration
The CLI can now initialize projects with Tailwind v4, and when you add new components, they'll be in the latest version.
For new projects:
npx shadcn@latest init
For adding components:
npx shadcn@latest add button
New Projects vs Upgrades
Important distinction: This is non-breaking. Your existing apps with Tailwind v3 and React 18 will still work. When you add new components, they'll still be in v3 and React 18 until you upgrade.
New projects automatically start with Tailwind v4 and React 19.
Migrating from Tailwind CSS 3 to 4 with shadcn/ui is straightforward thanks to the official upgrade tool. The CSS-first configuration takes some getting used to, but the performance improvements are significant. The combination of Tailwind v4's speed, React 19's improvements, and shadcn/ui's beautiful components provides an excellent foundation for modern web applications.
Take your time with the migration, test thoroughly, and enjoy the performance benefits!