Tailwind CSS v4 vs v3: what changed and how to upgrade
Compare Tailwind CSS v4 and v3: @theme in CSS, OKLCH colours, renamed utilities, breaking defaults, and the exact upgrade steps with @tailwindcss/upgrade.
- Tailwind CSS 4.3.5
Tailwind CSS v4 replaced the JavaScript config file with CSS-first configuration (@theme), switched its engine to Oxide (written in Rust), moved the default colour palette to OKLCH, and dropped several v3 utilities. Here is what actually changes in day-to-day code and how to upgrade cleanly.
Key differences between v3 and v4
| Area | Tailwind CSS v3 | Tailwind CSS v4 |
|---|---|---|
| Setup | @tailwind base/components/utilities; + tailwind.config.js | Single @import "tailwindcss"; + @theme {} in CSS |
| Content paths | Manual content: ["./src/**/*"] array | Automatic project scanning (override with @source) |
| Vite / PostCSS | tailwindcss PostCSS plugin | @tailwindcss/vite (or @tailwindcss/postcss) |
| Colour format | RGB / hex defaults | OKLCH defaults (wider gamut, cleaner contrast) |
| Dark mode class | darkMode: "class" in JS | @custom-variant dark (&:where(.dark, .dark *)); |
| Container queries | Separate @tailwindcss/container-queries plugin | Built in (@container, @md:grid-cols-2) |
| CSS modules / scoped styles | @apply worked implicitly | Needs @reference "../global.css"; |
Breaking utility renames that trip up upgrades
- Border & ring defaults:
bordernow usescurrentColorinstead ofgray-200, andringis1pxinstead of3px. Set an explicit colour (border-border) or add a base rule if migrating an older codebase. - Shadow & radius scale shifted by one step:
shadow-smbecameshadow-xs,shadowbecameshadow-sm;rounded-smbecamerounded-xs,roundedbecamerounded-sm. - Opacity utilities removed:
bg-opacity-50andtext-opacity-75are gone — use slash syntax (bg-black/50,text-ink/75). - Important modifier moved to the end:
!flexis nowflex!. - CSS variables in arbitrary values:
bg-[--brand]is nowbg-(--brand).
How to upgrade a v3 project
Step 1: Run the official upgrade codemod on a clean Git branch
Terminalnpx @tailwindcss/upgradeIt updates dependencies, migrates
tailwind.config.jsinto@theme, and rewrites renamed utilities across your templates.Step 2: Fix shadcn/ui imports if you use shadcn
Replace
tailwindcss-animatewithtw-animate-cssand check that your tokens don't double-wraphsl(var(--background)). See shadcn/ui not working with Tailwind v4.Step 3: Add @reference to scoped style blocks
If Astro, Vue or Svelte
<style>blocks throw "Cannot apply unknown utility class", see Tailwind v4 @apply not working.
Questions
Can I keep tailwind.config.js in Tailwind v4?
Yes, temporarily, by loading it with @config "./tailwind.config.js"; in your main CSS file. For new projects, stick with @theme; see Does Tailwind CSS v4 have a config file?
Do themes.dev blocks work on Tailwind CSS v4?
Yes. Every block and component in our catalogue is built natively for Tailwind CSS v4 and shadcn/ui.
Related articles
- Tailwind CSS v4Does Tailwind CSS v4 have a config file?Not by default: v4 is configured in CSS with @theme. Where every v3 setting went, how to load an old tailwind.config.js with @config, and when to keep it.
- Tailwind CSS v4Tailwind v4 @apply not working: unknown utility class errorStyle blocks in Astro, Vue and Svelte and CSS modules need @reference in v4. Custom classes need @utility. The error, the fix and the other causes.
- Tailwind CSS v4Tailwind v4 with Vite not working: plugin and CSS fixesFix Tailwind CSS v4 in Vite, React and Astro: register @tailwindcss/vite, remove leftover postcss.config.js, import tailwindcss, and configure @source.
Still stuck? We answer every message ourselves. Write to us