If you learned Tailwind CSS from a tutorial written before 2025, half of what you memorised is now wrong. Tailwind CSS v4 — released on 22 January 2025, and now at version 4.3.5 — rebuilt the framework from the ground up: configuration moved out of JavaScript and into CSS, the build engine was rewritten in Rust, and the install you are used to no longer exists. The good news is that the new way is simpler. This guide covers installing Tailwind CSS v4, configuring it with @theme, building real components, adding dark mode and container queries, and migrating a v3 project. Everything here was verified against the official Tailwind documentation and release notes on 16 November 2026.
What Actually Changed in Tailwind CSS v4
Version 4 is not a feature release with a few new utilities. It is a rewrite, and four changes drive almost everything else:
- CSS-first configuration. There is no
tailwind.config.jsany more. You configure design tokens — colours, fonts, breakpoints — in CSS with the@themedirective, in the same file where you import Tailwind. A legacy JavaScript config can still be loaded with@config, but that is a migration bridge, not the way forward. - A new engine. The Oxide engine, written in Rust, replaces the old JavaScript-based build. Tailwind’s own benchmarks on its Catalyst project show full builds dropping from 378ms to 100ms, and incremental rebuilds that need no new CSS completing in 192 microseconds — over 100x faster.
- Automatic content detection. The v3
contentarray is gone. Tailwind v4 scans your project automatically and ignores anything in your.gitignore, so dependencies and build output never get scanned. If a source sits outside the default scan, you point at it with@sourcein CSS. - A modernised palette. The whole default colour palette moved from sRGB to OKLCH, making colours noticeably more vivid on modern displays. Tailwind kept the balance between colours the same as v3, so existing designs should not look different — just richer where the old gamut held them back.
On top of that, v4 adds dynamic utility values — grid-cols-15 works out of the box, as does w-17, because spacing utilities are now derived from a single --spacing variable — plus built-in container queries, 3D transforms, and a much larger gradient API. The price is a higher browser floor: v4 targets Safari 16.4+, Chrome 111+, and Firefox 128+. If you must support older browsers, stay on v3.4.
Install Tailwind CSS v4
The Vite plugin is the recommended route, and it is also how Laravel, Nuxt, and SvelteKit projects wire Tailwind in. The official Vite guide lists four steps:
npm install tailwindcss @tailwindcss/vite
Add the plugin to your Vite config:
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [
tailwindcss(),
],
})
Then import Tailwind in your main CSS file — one line replaces the three @tailwind directives from v3:
@import "tailwindcss";
Start the dev server with npm run dev and you are done — no config file, no content array, no PostCSS config.
Two other routes exist. If your project already uses PostCSS, install the dedicated plugin instead — in v4 the PostCSS plugin lives in its own package, and you can drop postcss-import and autoprefixer because v4 handles imports and vendor prefixing itself:
npm install tailwindcss @tailwindcss/postcss
export default {
plugins: {
"@tailwindcss/postcss": {},
},
}
And if you have no build tool at all, the standalone CLI builds your CSS directly:
npx @tailwindcss/cli -i ./src/input.css -o ./src/output.css
One thing to avoid: the browser build loaded from a CDN script tag. It compiles styles in the visitor’s browser — handy for a quick prototype, but slower and not meant for production. The old v3 Play CDN address (cdn.tailwindcss.com) is worse: as a stylesheet link it styles nothing in v4, because it serves the v3 play script. Ship compiled CSS.
Your First Component: Build a Card
Utility-first CSS means you style in the markup. Here is a pricing card built with v4 utilities — nothing here needs configuration:
<div class="mx-auto max-w-sm rounded-2xl bg-white p-6 shadow-lg ring-1 ring-gray-900/5 dark:bg-gray-900 dark:ring-white/10">
<h3 class="text-base font-semibold tracking-tight text-gray-900 dark:text-white">
Pro plan
</h3>
<p class="mt-2 text-3xl font-bold text-gray-900 dark:text-white">
$12<span class="text-base font-medium text-gray-500">/month</span>
</p>
<p class="mt-2 text-sm leading-relaxed text-gray-500 dark:text-gray-400">
Everything in Free, plus unlimited projects and priority support.
</p>
<button class="mt-6 w-full rounded-lg bg-red-600 px-4 py-2 text-sm font-semibold text-white hover:bg-red-700 focus:outline-2 focus:outline-offset-2 focus:outline-red-600">
Upgrade now
</button>
</div>
Read the classes left to right and the design reads itself: centred, capped at the small breakpoint, rounded corners, a subtle ring instead of a border, and a full-width button that darkens on hover. The dark: variants flip the card to a dark background and light text when dark mode is on.
Configure Your Design with @theme
This is the single biggest mental shift in v4. Instead of a JavaScript config object, your design tokens live in CSS:
@import "tailwindcss";
@theme {
--font-display: "Satoshi", "sans-serif";
--breakpoint-3xl: 1920px;
--color-avocado-100: oklch(0.99 0 0);
--color-avocado-200: oklch(0.98 0.04 113.22);
--color-avocado-300: oklch(0.94 0.11 115.03);
--color-avocado-400: oklch(0.92 0.19 114.08);
--color-avocado-500: oklch(0.84 0.18 117.33);
--color-avocado-600: oklch(0.53 0.12 118.34);
--ease-fluid: cubic-bezier(0.3, 0, 0, 1);
--ease-snappy: cubic-bezier(0.2, 0, 0, 1);
}
Each token generates matching utilities automatically: --color-avocado-500 gives you bg-avocado-500, text-avocado-500, border-avocado-500, and every other colour utility. --breakpoint-3xl gives you a 3xl: variant. --font-display gives you font-display.
These tokens are also exposed as plain CSS variables: after the build, your :root contains --color-avocado-500 and friends as real custom properties, usable in inline styles, your own CSS, or animation libraries. That is the payoff for moving config into CSS — your design system becomes ordinary CSS.
A few practical rules for @theme:
- Define tokens, not utilities. If you find yourself writing the same five classes on every button, extract a component in your CSS instead of stacking
@applychains. Long@applyrules were already a smell in v3; in v4 the@utilitydirective exists for the cases where you genuinely need a custom utility that works with variants likehover:. - Use OKLCH for custom colours. The default palette is OKLCH, and mixing colour spaces in one design system produces muddy results. Pick colours with an OKLCH picker and paste the values in.
- Keep the default scale unless you have a reason. Every spacing utility derives from
--spacing, so overriding it ripples through your whole layout — do it deliberately, in a branch, and check the result visually.
Responsive Design and Variants
Tailwind is mobile-first: unprefixed classes apply at every screen size, and a breakpoint prefix applies from that width upwards. A grid that is one column on a phone and three on a desktop is one line:
<div class="grid grid-cols-1 gap-4 md:grid-cols-3">
<!-- cards -->
</div>
Variants stack the same way. hover:bg-red-700, focus:outline-2, disabled:opacity-50 — each is a condition on the same utility. v4 adds two variants worth knowing on day one. The not-* variant styles an element only when it does not match something else. And data-attribute variants work without any configuration now: data-current:opacity-100 targets an element with a data-current attribute, so you can drive active states from your markup instead of inventing classes for them.
The other habit to build early: never construct class names dynamically. A template string like `text-${color}-500` produces a class name Tailwind’s scanner never sees in your source files, so the CSS is never generated and the style silently does nothing. Write the full class names out, or map values to complete class strings in your code.
Dark Mode the v4 Way
By default, the dark: variant follows the operating system’s prefers-color-scheme setting. That is the right default for most sites — it costs you nothing and respects the user’s choice. But most products eventually want a manual toggle, and in v4 that is a one-line override in your CSS:
@import "tailwindcss";
@custom-variant dark (&:where(.dark, .dark *));
Now dark: utilities apply whenever a .dark class exists anywhere up the tree. Add the class to <html> with a small script that reads localStorage and falls back to the OS preference — the official docs ship this snippet. A data attribute works the same way, with [data-theme=dark] as the selector.
One design note: dark mode is not “the same page with darker colours”. Text that was text-gray-500 on white usually needs to go lighter, not just inverted — dark:text-gray-400 on a dark surface reads better than a straight swap. Check your dark palette on a real device, because contrast that looks fine on a bright monitor can vanish on a phone in sunlight.
Container Queries Are Built In
Media queries answer “how wide is the viewport”. Container queries answer “how wide is the thing I am inside” — which is the question a reusable component actually needs. v4 ships them in core, no plugin required:
<div class="@container">
<div class="grid grid-cols-1 @sm:grid-cols-3 @lg:grid-cols-4">
<!-- cards that adapt to their container, not the viewport -->
</div>
</div>
Mark the container with @container, then use @sm:, @lg:, and friends the way you use sm: and lg:. There are also max-width variants — @max-md:grid-cols-1 — and you can stack ranges, like @min-md:@max-xl:hidden.
The classic use case is a card that appears in a sidebar on one page and full-width on another: it lays itself out correctly in both, with no props, no JavaScript, and no duplicate markup.
What Landed in v4.1, v4.2, and v4.3
Version 4.0 was the rewrite; the releases since have been steady additions. The current version is 4.3.5, and this is what each minor release added that working developers will actually notice.
v4.1 (April 2025) finally shipped text-shadow-* utilities — five sizes from text-shadow-2xs to text-shadow-lg, with colour and opacity modifiers — plus composable mask-* utilities for fading elements with gradients, pointer-fine and pointer-coarse variants so touch targets can grow on touchscreens, and @source not / @source inline(...) for controlling exactly which files get scanned. It also added fallbacks so sites degrade more gracefully in older browsers — OKLCH colours now render in Safari 15, for example — though v4 is still designed for modern browsers.
v4.2 (February 2026) added four new colour palettes (mauve, olive, mist, and taupe), a first-party @tailwindcss/webpack package, more logical-property utilities for RTL-friendly layouts, and font-features utilities.
v4.3 (May 2026) added first-party scrollbar styling — scrollbar-thin, scrollbar-thumb-*, scrollbar-track-*, and scrollbar-gutter-* to stop layout shift when scrollbars appear — plus zoom-* and tab-* utilities, an @container-size utility that exposes a container’s own size for use inside it, and stacked and compound variants in the @variant directive.
None of these change how you write Tailwind day to day, but they delete plugins and workarounds: the scrollbar plugin, the container-queries plugin, and hand-rolled text-shadow utilities can all go.
Migrate from v3 Without the Tears
If you have a v3 project, do not hand-migrate it. Run the official upgrade tool in a fresh branch and review the diff:
npx @tailwindcss/upgrade
It needs Node.js 20 or higher, and for most projects it automates the whole migration: dependencies, config-to-CSS conversion, and template updates. Then go through the breaking changes it flags. The ones that bite most often:
| v3 | v4 | What changes |
|---|---|---|
shadow-sm |
shadow-xs |
Shadow scale renamed; the bare shadow is now shadow-sm |
rounded-sm |
rounded-xs |
Radius scale renamed the same way |
blur-sm |
blur-xs |
Blur scale renamed the same way |
outline-none |
outline-hidden |
Old outline-none hid the outline but kept it visible in forced-colors mode; the new outline-none genuinely removes it |
ring |
ring-3 |
Ring is now 1px instead of 3px, and its default colour is currentColor, not blue |
bg-opacity-* |
bg-black/50 |
Opacity utilities removed; use the slash modifier on the colour |
flex-shrink-* |
shrink-* |
Renamed; same for flex-grow-* to grow-* |
The rename table is the trap most migrations fall into. The old names still work, but they do not look the same: shadow-sm in v4 is the old shadow, so a subtly shadowed card suddenly looks heavier. Run the upgrade tool, then search your templates for the renamed utilities and fix them deliberately.
Three quieter changes matter too. First, borders and dividers now default to currentColor instead of gray-200, so a bare border on dark text draws a dark line — add an explicit colour wherever you relied on the old default. Second, buttons now use cursor: default instead of cursor: pointer; if your users expect a pointer, restore it with a base style. Third, the space-x-* and space-y-* utilities use a different selector now, and the docs recommend gap on a flex or grid container instead.
7 Mistakes That Break Tailwind v4 Projects
- Copying a v3 setup. A
tailwind.config.js, three@tailwinddirectives, and acontentarray are the v3 shape. In v4 the config is ignored unless you load it with@config, and the directives do nothing. Start from the Vite install above. - Building class names dynamically.
`text-${color}-500`never reaches the scanner, so the style silently never exists. Use complete class names. - Shipping the Play CDN. The browser build is for prototypes. Production gets compiled CSS from your build step.
- Trusting the old utility names.
shadow-sm,rounded-sm, andblur-small shifted one step. After migrating, eyeball every card and modal. - Forgetting borders default to currentColor. Every bare
borderneeds an explicit colour now, or it inherits the text colour. - Hiding everything behind @apply. A 20-line
@applyblock is a component pretending to be a utility. Extract a real component class and keep your utilities honest. - Skipping the upgrade tool. Hand-editing a v3 project to v4 misses renames the tool catches mechanically. Run it in a branch, read the diff, then fix the judgement calls by hand.
Should You Stay on v3?
For a new project, no — v4 is current, it is faster, and every new feature lands there. The only honest reason to stay on v3.4 is browser support: if a meaningful share of your users is on Safari below 16.4, Chrome below 111, or Firefox below 128, v4 will not work for them at all, and v4.1’s fallbacks only soften that, they do not fix it. Check your analytics first; most developer-facing products cleared that bar years ago, and most consumer products in 2026 have too.
For an existing v3 project, the calculation is different. If it is stable and you rarely touch the CSS, leave it alone. If you are actively building in it, migrate: the upgrade tool does the mechanical work, the dev loop gets noticeably faster, and every tutorial from now on assumes v4. Budget an afternoon, not a sprint.
Tailwind CSS v4 rewards developers who read the upgrade guide once and stop fighting the framework. Configure in CSS, let the scanner find your classes, and use the new primitives — container queries, dynamic values, @theme tokens — instead of bolting plugins onto a v3-shaped project. The framework got simpler. Let your setup get simpler too.
Verified 16 November 2026 against the official Tailwind CSS documentation and release notes. Current version at time of writing: Tailwind CSS 4.3.5.
Further Reading & References
- Tailwind CSS v4.0 — the official v4.0 announcement: the Oxide engine, CSS-first configuration, dynamic utilities, container queries, and the benchmark numbers.
- Installing Tailwind CSS with Vite — the official install guide used for the setup steps in this post.
- Upgrade guide — the full v3 to v4 breaking-change list, including every renamed and removed utility.
- Tailwind CSS v4.1: Text shadows, masks, and tons more — the official v4.1 release notes.
- Tailwind CSS v4.3: Scrollbars, new colors, and more — the official v4.3 release notes, covering v4.2 as well.
- Dark mode — the official guide to the
dark:variant and the class-based toggle. - Scrollbar Styling and Container Size Utilities in Tailwind CSS v4.3.0 — Laravel News on the v4.3 release, useful if you use Tailwind with Laravel.
- Tailwind CSS v4 in 2026: What Is New Since 4.0 and How to Migrate — a version-by-version timeline of the 4.1–4.3 releases.
Related on HowToShipIt: Nuxt 3 SEO: The Complete Guide to Meta Tags, Sitemaps, and OG Images (2026) and Vue 3 Composition API Migration: Options API to script setup, Step by Step (2026).



