All posts
csstailwind

Tailwind v4: The Migration Notes I Wish I'd Had

The config file is gone, a few class names quietly changed meaning, and one theme setting will confuse you. Here's the short list.

Muhamad Choirul Adam 3 min readPhoto: Unsplash

Tailwind v4 came out on January 22. The headline is speed: a new engine, full builds several times faster, and incremental rebuilds that are close to instant. That's real, but it's not what you'll spend upgrade day on.

What you'll spend it on is a handful of changes that don't throw errors. Your build passes, and some borders look different.

Rendering diagram…

The config moved into CSS

There's no tailwind.config.js by default anymore. Setup is one import, and your design tokens live in CSS:

globals.css
@import "tailwindcss";
 
@theme {
  --color-brand: #c8f560;
  --font-display: "Space Grotesk", sans-serif;
}

That gives you bg-brand and font-display, and every token is also a real CSS variable you can use anywhere with var(--color-brand). Content detection is automatic too, so the content: [...] array is gone.

If you're not ready to move everything, @config "./tailwind.config.js"; still loads the old file.

Run the upgrade tool first

npx @tailwindcss/upgrade

It rewrites your CSS entry, moves the theme over, and renames classes in your templates. It does most of the work. Then read the diff, because the next section is what it can't judge for you.

Changes that pass the build and still change the UI

These are the ones that caught me:

v3v4Why it bites
shadow-smshadow-xsThe whole scale shifted down one step
rounded-smrounded-xsSame shift for radius
outline-noneoutline-hiddenoutline-none now really removes it
ring (3px)ring-3Plain ring is now 1px
border (gray-200)border border-gray-200Default border color is currentColor
bg-opacity-50bg-black/50Opacity utilities are gone
!font-boldfont-bold!The important modifier moved to the end

The border one is the sneakiest. Every bare border in your app turns from light gray to the text color. On a dark theme with white text, that's a lot of bright lines.

The one setting that will confuse you: @theme inline

When a token points at another variable, like a font loaded by next/font, you'll see @theme inline in examples:

@theme inline {
  --font-sans: var(--font-geist);
}

inline makes the utility use the value directly instead of going through a --font-sans variable. That's fine for utilities. But if plain CSS somewhere else reads var(--font-sans), that variable now holds Tailwind's default, not yours. I lost an hour to code blocks rendering in the wrong font for exactly this reason.

Rule of thumb: use @theme inline for tokens only utilities read. Use plain @theme for anything your own CSS also reads.

Things that got better

  • Container queries are built in. @container on the parent, @sm: and @lg: on the children. No plugin.
  • not-* variants. not-hover:opacity-70 reads better than the workarounds it replaces.
  • Real cascade layers. Your own component CSS in @layer components loses to utilities, as it should, without !important.

Check your browsers before you start

v4 depends on modern CSS: cascade layers, @property, and color-mix(). It targets Safari 16.4+, Chrome 111+, and Firefox 128+. If you still support older browsers, stay on v3.4 for now. That's a product decision, not a technical one, so ask before you upgrade.