Skip to content

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.

Updated 3 December 2026Tested with
  • 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

AreaTailwind CSS v3Tailwind CSS v4
Setup@tailwind base/components/utilities; + tailwind.config.jsSingle @import "tailwindcss"; + @theme {} in CSS
Content pathsManual content: ["./src/**/*"] arrayAutomatic project scanning (override with @source)
Vite / PostCSStailwindcss PostCSS plugin@tailwindcss/vite (or @tailwindcss/postcss)
Colour formatRGB / hex defaultsOKLCH defaults (wider gamut, cleaner contrast)
Dark mode classdarkMode: "class" in JS@custom-variant dark (&:where(.dark, .dark *));
Container queriesSeparate @tailwindcss/container-queries pluginBuilt in (@container, @md:grid-cols-2)
CSS modules / scoped styles@apply worked implicitlyNeeds @reference "../global.css";

Breaking utility renames that trip up upgrades

  • Border & ring defaults: border now uses currentColor instead of gray-200, and ring is 1px instead of 3px. Set an explicit colour (border-border) or add a base rule if migrating an older codebase.
  • Shadow & radius scale shifted by one step: shadow-sm became shadow-xs, shadow became shadow-sm; rounded-sm became rounded-xs, rounded became rounded-sm.
  • Opacity utilities removed: bg-opacity-50 and text-opacity-75 are gone — use slash syntax (bg-black/50, text-ink/75).
  • Important modifier moved to the end: !flex is now flex!.
  • CSS variables in arbitrary values: bg-[--brand] is now bg-(--brand).

How to upgrade a v3 project

  1. Step 1: Run the official upgrade codemod on a clean Git branch

    Terminal
    npx @tailwindcss/upgrade

    It updates dependencies, migrates tailwind.config.js into @theme, and rewrites renamed utilities across your templates.

  2. Step 2: Fix shadcn/ui imports if you use shadcn

    Replace tailwindcss-animate with tw-animate-css and check that your tokens don't double-wrap hsl(var(--background)). See shadcn/ui not working with Tailwind v4.

  3. 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.

Was this page helpful?

Still stuck? We answer every message ourselves. Write to us

Building with shadcn/ui and Tailwind CSS v4?

Install 188 free blocks and components with the shadcn CLI (no account), preview them in your own brand in Studio, or get all 1,570 blocks and every theme in UI Pro (€199 once).

Use it with

This page is built from UI Pro parts: the docs article block (docs-quernly) with the code, terminal, install command, steps, contents and feedback components, included in UI Pro.