Tailwind CSS has been the dominant way developers write styles on the web for over five years. But as build systems transitioned from Webpack to high-speed tools like Vite, Esbuild, and Turbopack, Tailwind’s Javascript-heavy configuration and PostCSS parsing engine began to feel like a performance bottleneck.

With the release of Tailwind CSS v4, the framework has been completely rewritten.

Tailwind Labs calls Tailwind CSS v4.0 “a ground-up rewrite of the framework,” released on January 22, 2025. The headline claim is that “full builds are up to 5x faster, and incremental builds are over 100x faster.” More importantly, it stops relying on tailwind.config.js and moves to a CSS-first configuration model.

This blog runs on Tailwind CSS 4.3 with Astro 6, so the setup below is the same one serving this page. Here is a practical guide to upgrading your codebase and using Tailwind v4’s new features.


1. Tailwind CSS v4 Performance and the Vite Plugin

In Tailwind v3, the tailwindcss package was a PostCSS plugin, and you usually paired it with postcss-import and autoprefixer. Tailwind v4 rewrote the engine and now uses Lightning CSS under the hood for vendor prefixing and modern syntax transforms, so those two extra plugins can go.

These are the median timings Tailwind Labs published, measured against its Catalyst UI kit:

Build typev3.4v4.0Speed-up
Full build378ms100ms3.78x
Incremental, new CSS44ms5ms8.8x
Incremental, no new CSS35ms192µs182x

(Source: Tailwind Labs, Tailwind CSS v4.0, Jan 2025)

The same post is more modest about real projects: “we’ve found full rebuilds to be over 3.5x faster, and incremental builds to be over 8x faster.” I would quote that number to your team, not the 182x one. The 182x case is a rebuild where you edited a file but used no class Tailwind had not already generated, which is common but not the whole story.

  • Vite-native plugin: Tailwind recommends @tailwindcss/vite over the PostCSS plugin “for improved performance and the best developer experience.”
  • PostCSS still works: the plugin moved to the separate @tailwindcss/postcss package.
  • CLI moved too: npx tailwindcss becomes npx @tailwindcss/cli.

For example, in a modern Astro project:

// astro.config.mjs
import { defineConfig } from 'astro/config';
import tailwind from '@tailwindcss/vite';

export default defineConfig({
  vite: {
    plugins: [tailwind()],
  },
});

2. CSS-First Configuration: Goodbye tailwind.config.js

The most visible change in Tailwind v4 is that tailwind.config.js is no longer the default.

In v3, defining a custom color palette or font family required writing massive Javascript objects. In v4, your CSS file is the configuration file.

You now import Tailwind and configure your theme using the standard CSS @theme directive:

/* src/styles/global.css */
@import "tailwindcss";

@theme {
  --font-sans: "Outfit Variable", sans-serif;
  --font-serif: "Source Serif 4 Variable", serif;

  --color-primary: #d4380d;
  --color-accent: #fa541c;
  --color-background-warm: #fafaf8;
  
  --spacing-128: 32rem;
}

How this compiles:

When Tailwind reads your CSS file:

  1. It parses the custom CSS custom properties (variables) defined inside @theme.
  2. It automatically generates the corresponding utility classes—for example, --color-primary immediately yields bg-primary, text-primary, and border-primary.
  3. It exposes these custom properties globally, meaning they are also standard CSS variables you can use in raw CSS files: background-color: var(--color-primary).

Your old JavaScript config is not dead, just demoted. The upgrade guide says JS config files “are still supported for backward compatibility, but they are no longer detected automatically,” and you load one explicitly with @config "../../tailwind.config.js";. The corePlugins, safelist and separator options are not supported in v4.0, which is the part that bites people with big legacy configs.

3. Automatic Content Detection in Tailwind v4

In Tailwind v3, you had to explicitly configure the content array to tell the compiler where your HTML, JSX, and TSX files lived:

// Legacy tailwind.config.js
module.exports = {
  content: ["./src/**/*.{html,js,jsx,ts,tsx,astro}"],
}

If you forgot to add a folder path, your utility classes wouldn’t compile, resulting in unstyled pages.

Tailwind v4 removes the content array. It does not read your bundler’s dependency graph; it scans every file in the project with a set of heuristics. According to the content detection docs, it skips:

  • files listed in your .gitignore
  • the node_modules directory
  • binary files such as images, videos and zip files
  • CSS files and common package manager lock files

That default catches one real trap. If you use a component library built with Tailwind, it lives in node_modules, so its classes are ignored until you register it with @source "../node_modules/@my-company/ui-lib";. You can also exclude folders with @source not or turn detection off completely with @import "tailwindcss" source(none);.

The other trap is older than v4 and still catches AI-generated code. Tailwind treats source files as plain text, so a class built by string interpolation such as `bg-${color}-600` never exists in the source and never gets generated. Map props to complete class names instead. I see this mistake constantly in code from the builders in my Lovable vs Bolt.new vs v0 comparison, since all of them lean on Tailwind for styling.


4. Declaring Custom Utilities Natively

In Tailwind v3, adding custom utility classes required writing Javascript plugins or using complex CSS structures. In v4, you can write custom utilities natively in your CSS file using the @utility directive:

/* Custom utility declaration */
@utility scrollbar-hide {
  &::-webkit-scrollbar {
    display: none;
  }
  -ms-overflow-style: none;
  scrollbar-width: none;
}

This registers scrollbar-hide as a first-class Tailwind class, complete with support for variants like hover:scrollbar-hide and responsive breakpoints like md:scrollbar-hide.


5. Tailwind v4 Renamed Utilities That Change Your UI

The upgrade guide lists several renames that do not throw errors. Your build passes and your buttons quietly look different:

v3 classv4 equivalentWhat changed
shadow-smshadow-xsScale shifted down one step
shadowshadow-smScale shifted down one step
rounded-smrounded-xsScale shifted down one step
roundedrounded-smScale shifted down one step
outline-noneoutline-hiddenOld class never set outline-style: none
ringring-3Default ring went from 3px to 1px

(Source: Tailwind CSS upgrade guide)

Two more defaults moved. Borders and dividers now use currentColor instead of gray-200, so every bare border class changes colour unless you add the base-layer override from the guide. And the deprecated *-opacity-* utilities are gone in favour of modifiers like bg-black/50.

Tailwind CSS v4 Browser Support

Tailwind CSS v4.0 targets Safari 16.4+, Chrome 111+ and Firefox 128+. The upgrade guide is blunt about it: if you need older browsers, “stick with v3.4 until your browser support requirements change.”

It is also “not designed to be used with CSS preprocessors like Sass, Less, or Stylus,” which rules out Sass in Vue, Svelte or Astro <style> blocks. Check both before you promise anyone a one-day migration.

6. Upgrade Checklist for Tailwind v4

If you are migrating a production application from v3 to v4, follow this checklist:

  1. Run the upgrade tool on a branch: npx @tailwindcss/upgrade needs Node.js 20 or higher, and Tailwind Labs recommends running it in a new branch and reviewing the diff in a browser.
  2. Swap packages: Install tailwindcss with @tailwindcss/vite, or @tailwindcss/postcss if you stay on PostCSS. Remove postcss-import and autoprefixer.
  3. Rewrite imports: Replace @tailwind base; @tailwind components; @tailwind utilities; with a single @import "tailwindcss";.
  4. Migrate theme config: Move theme values into @theme, or keep the old file temporarily with @config.
  5. Fix the silent renames: search for shadow, rounded, ring, outline-none and bare border classes.
  6. Register ignored sources: add @source for any Tailwind-styled package in node_modules.

A Streamlined Developer Experience

Tailwind CSS v4 is a big step, and the v4.x line has kept moving since, with v4.3.4 on GitHub as the latest release at the time of this update. Aligning with native CSS custom properties makes configuration simpler, and the build-time gains are real even if the 182x figure only applies to one kind of rebuild.

Writing styles feels less like configuring a library, and more like writing modern, standard CSS. If you are pairing it with Astro, my guide to Astro server islands and React 19 covers the other half of keeping client JavaScript small.

(Updated November 5, 2026: corrected the performance claims. Tailwind Labs reports full builds up to 5x and incremental builds over 100x faster, not a blanket 10x, and its announcement does not describe the engine as Rust-based. Also corrected the content detection section: v4 scans project files with heuristics and skips gitignored files and node_modules rather than reading the bundler graph, and JavaScript config files are still supported via @config.)