Tailwind CSS v4 Breaking Changes: The Full List and the Fix for Each
Derar SattoufNext.js & frontend

Tailwind CSS v4 changed how the framework is installed and configured, renamed part of its scales, and changed several defaults. Some of these changes break your build, which is annoying but safe: you see the error and fix it. Others compile without a warning and quietly change how your pages look. Those are the ones that reach production.
The short version:
- Run
npx @tailwindcss/upgradeon a new branch. It needs Node.js 20 or newer, and it handles most of the renames below in your templates and your config. - Fix the build errors it leaves (setup, config,
@applyin components). - Search for the silent changes in this post, especially in class names the tool cannot see: strings built in JavaScript, content from a CMS, classes in files outside your project.
- Compare the pages visually before you merge. Borders, rings, small shadows and placeholders are the usual places where something looks different.
Every class in this post was compiled with Tailwind CSS 4.3.3, the release current at the time of writing, to check what it actually outputs. For the migration as a whole, including CSS-first configuration and design tokens, see the Tailwind CSS v4 migration guide.
Changes that break the build
These fail loudly. You will meet them in the first hour.
@tailwind directives are gone
/* v3 */
@tailwind base;
@tailwind components;
@tailwind utilities;
/* v4 */
@import "tailwindcss";The packages moved
| Integration | v3 | v4 |
|---|---|---|
| PostCSS | tailwindcss as a PostCSS plugin | @tailwindcss/postcss |
| Vite | PostCSS | @tailwindcss/vite (recommended over PostCSS for Vite) |
| CLI | npx tailwindcss -i input.css -o output.css | npx @tailwindcss/cli -i input.css -o output.css |
With the PostCSS plugin, remove postcss-import and autoprefixer; v4 handles imports and vendor prefixes itself.
// postcss.config.mjs
export default {
plugins: {
"@tailwindcss/postcss": {},
},
};The JavaScript config is no longer loaded automatically
v4 is configured in CSS with @theme. A tailwind.config.js still works, but only if you load it explicitly:
@import "tailwindcss";
@config "../../tailwind.config.js";Three options from v3 configs are not supported at all: corePlugins, safelist and separator. Replace safelist with @source inline() in CSS:
@source inline("bg-red-500 bg-green-500 text-white");resolveConfig was removed
Code that imported resolveConfig to read theme values in JavaScript breaks. Every theme value is now a CSS variable, so read that instead:
const shadow = getComputedStyle(document.documentElement).getPropertyValue("--shadow-xl");Animation libraries that accept CSS values can use the variable directly, for example backgroundColor: "var(--color-blue-500)".
theme() uses variable names
Prefer the CSS variable everywhere: var(--color-red-500) instead of theme(colors.red.500). Where you still need theme(), such as inside a media query, use the variable name instead of dot notation:
/* v3 */
@media (width >= theme(screens.xl)) { ... }
/* v4 */
@media (width >= theme(--breakpoint-xl)) { ... }@apply in Vue, Svelte, Astro and CSS modules
A <style> block in a component, or a CSS module, is compiled separately from your main stylesheet, so it cannot see your theme, custom utilities or custom variants. @apply with your own classes then fails. Add @reference at the top of the block. It makes the definitions available without adding any CSS to the bundle:
<style scoped>
@reference "../../app.css";
h1 {
@apply text-2xl font-bold text-red-500;
}
</style>Or skip @apply and use the variables: color: var(--color-red-500);. That is also faster, because Tailwind does not need to process the block.
Sass, Less and Stylus
Tailwind v4 is not designed to be used with CSS preprocessors, including in <style> blocks in Vue, Svelte or Astro. Move nesting and variables to plain CSS, which v4 supports, or keep the preprocessor away from the files Tailwind processes.
Custom utilities use @utility
v4 uses native cascade layers and no longer treats classes inside @layer utilities or @layer components as utilities. Use @utility:
/* v3 */
@layer utilities {
.tab-4 {
tab-size: 4;
}
}
/* v4 */
@utility tab-4 {
tab-size: 4;
}The same applies to component classes such as .btn. A side effect worth knowing: utilities created this way are sorted by how many properties they set, so a single-property utility like px-6 can override your btn utility without any extra configuration.
The container options are gone
center and padding for container no longer exist in the config. Recreate them:
@utility container {
margin-inline: auto;
padding-inline: 2rem;
}Prefixes look like variants
If you used a prefix, it now comes first, before every variant:
@import "tailwindcss" prefix(tw);<div class="tw:flex tw:bg-red-500 tw:hover:bg-red-600">Theme variables are still declared without the prefix (--font-display), but the generated CSS variables carry it (--tw-font-display).
Browser support
v4 targets Safari 16.4, Chrome 111 and Firefox 128. It relies on @property, color-mix() and cascade layers, and does not work in older browsers. If you must support them, stay on v3.4.
Changes that silently change your UI
These compile without errors. Search for each one.
The shadow, radius and blur scales moved down one step
A new smallest size (xs) was added, so every old name below the default shifted:
| v3 class | v4 class with the same look |
|---|---|
shadow-sm | shadow-xs |
shadow | shadow-sm |
drop-shadow-sm | drop-shadow-xs |
drop-shadow | drop-shadow-sm |
blur-sm | blur-xs |
blur | blur-sm |
backdrop-blur-sm | backdrop-blur-xs |
backdrop-blur | backdrop-blur-sm |
rounded-sm | rounded-xs |
rounded | rounded-sm |
The trap is the -sm classes. They still exist in v4, but they now mean the next size up. A card with v3's shadow-sm gets a visibly heavier shadow in v4, and a rounded-sm button gets a larger radius (0.25rem instead of 0.125rem). The bare names (shadow, rounded, blur) still compile to their old values for compatibility, but rename them too, so the scale reads consistently.
If you rename by hand, do the -sm classes first. Otherwise shadow becomes shadow-sm, and a later shadow-sm to shadow-xs pass renames it a second time.
outline-none became outline-hidden
In v3, outline-none did not remove the outline. It made it transparent, so it still appeared in Windows high contrast mode (forced colors), which is what keyboard users there rely on to see focus. In v4 that behaviour is called outline-hidden, and outline-none really sets outline-style: none.
So a v3 focus:outline-none left unchanged now removes the focus indicator completely in forced colors mode. Replace it:
<!-- v3 -->
<input class="focus:outline-none focus:ring-2" />
<!-- v4 -->
<input class="focus:outline-hidden focus:ring-2" />Related: outline alone now means a 1px outline, and every outline-<number> sets outline-style: solid itself, so outline outline-2 becomes just outline-2.
ring is 1px and uses the current color
In v3, a bare ring was 3px wide and blue (blue-500). In v4 it is 1px and uses currentColor. A focus ring that relied on the defaults becomes a thin line in the text color.
<!-- v3 -->
<button class="focus:ring">
<!-- v4: same look as before -->
<button class="focus:ring-3 focus:ring-blue-500">If you have many of these and need time, there is a compatibility setting, which the guide says exists only for compatibility:
@theme {
--default-ring-width: 3px;
--default-ring-color: var(--color-blue-500);
}Borders and dividers use the current color
v3 gave border and divide-* a default color of gray-200. v4 uses currentColor, so a plain border on dark text becomes a dark line. Always set a color: border border-gray-200. To restore the old default site-wide while you clean up:
@layer base {
*,
::after,
::before,
::backdrop,
::file-selector-button {
border-color: var(--color-gray-200, currentColor);
}
}space-* and divide-* use a new selector
In v3, space-y-4 added a top margin to every child except the first. In v4 it adds a bottom margin to every child except the last:
/* v3 */
.space-y-4 > :not([hidden]) ~ :not([hidden]) { margin-top: 1rem; }
/* v4 (4.3.3 output, simplified) */
:where(.space-y-4 > :not(:last-child)) { margin-block-end: 1rem; }Lists of block elements look the same. Layouts with inline children, hidden children, or children that set their own margins can shift. divide-* changed the same way. The robust fix is to switch to flex or grid with gap: flex flex-col gap-4.
Placeholders, buttons, dialogs and hidden
Four Preflight (base style) changes:
- Placeholder text is now the current text color at 50% opacity, instead of
gray-400. - Buttons use
cursor: defaultinstead ofcursor: pointer, matching how browsers style buttons. <dialog>has its margins reset, so it is no longer centered by default. Addm-autoor a base style.- The
hiddenattribute now wins over display utilities, so<div hidden class="flex">stays hidden. Remove the attribute to show the element.hidden="until-found"is not affected.
To keep the pointer cursor on buttons:
@layer base {
button:not(:disabled),
[role="button"]:not(:disabled) {
cursor: pointer;
}
}hover only applies on devices that can hover
v4 wraps hover: in @media (hover: hover). On phones and tablets, hover styles no longer stick after a tap, which is usually what you want. If your interface relied on hover for something important on touch screens, that part no longer works. Treat hover as an enhancement, or restore the old behaviour:
@custom-variant hover (&:hover);Variables in arbitrary values use parentheses
<!-- v3 -->
<div class="bg-[--brand-color]">
<!-- v4 -->
<div class="bg-(--brand-color)">This one is easy to miss. The v3 form does not cause an error in v4: bg-[--brand-color] compiles to background-color: --brand-color;, which is invalid CSS, so the browser drops it and the element has no background.
Commas in grid and object-position values
grid-cols-[max-content,auto] no longer turns the comma into a space. It compiles to grid-template-columns: max-content,auto;, which is invalid, and the grid falls back to a single column. Use underscores: grid-cols-[max-content_auto]. The same applies to grid-rows-* and object-*.
Transforms are individual properties
rotate-*, scale-* and translate-* now set the CSS rotate, scale and translate properties instead of one combined transform. Two consequences:
transform-noneno longer resets them. Usescale-none,rotate-noneortranslate-none.- A custom transition list that includes
transform, such astransition-[opacity,transform], stops animating them. List the properties:transition-[opacity,scale].
transition now includes outline-color
transition and transition-colors animate outline-color too. An outline that appears on hover with a color set only on hover will fade in from the current text color. Set the outline color unconditionally:
<!-- v3 -->
<button class="transition hover:outline-2 hover:outline-cyan-500">
<!-- v4 -->
<button class="outline-cyan-500 transition hover:outline-2">Gradients keep their values across variants
In v3, a variant that changed one gradient stop reset the others. In v4 the other stops are kept, which is more consistent but can leave a three-color gradient where you expected two. Use via-none to drop the middle stop in a variant:
<div class="bg-linear-to-r from-red-500 via-orange-400 to-yellow-400 dark:via-none dark:from-blue-500 dark:to-teal-400">Stacked variants apply left to right
v3 applied stacked variants from right to left; v4 applies them from left to right. Most stacks are unaffected. The ones that change are order-sensitive stacks with * or typography variants:
<!-- v3 -->
<ul class="first:*:pt-0 last:*:pb-0">
<!-- v4 -->
<ul class="*:first:pt-0 *:last:pb-0">Deprecated, but still working
These still compile in Tailwind 4.3.3, so nothing breaks yet. Clean them up while you are in the code; the upgrade tool converts them.
| v3 | v4 | Status in 4.3.3 |
|---|---|---|
bg-opacity-50 (and text-, border-, divide-, ring-, placeholder-opacity-*) | bg-black/50 | Removed: produces no CSS |
flex-shrink-0 | shrink-0 | Still compiles |
flex-grow | grow | Still compiles |
overflow-ellipsis | text-ellipsis | Still compiles |
decoration-slice / decoration-clone | box-decoration-slice / box-decoration-clone | Still compile |
bg-gradient-to-r | bg-linear-to-r | Still compiles |
!flex (important first) | flex! (important last) | Still compiles, deprecated |
The opacity utilities are the only ones here that fail. bg-opacity-50 simply produces no CSS, so the background goes back to fully opaque. Use the slash modifier on the color instead: bg-black/50, text-gray-900/80.
ring-inset and inset-ring
ring-inset was not removed. In 4.3.3 it still works the way it did in v3: it moves the ring to the inside of the element.
inset-ring-* is new. It is a separate inset ring with its own width and color, drawn in its own layer of the box shadow, so an element can have an outer ring and an inner ring at the same time:
<!-- one ring, drawn inside (works in v3 and v4) -->
<button class="ring-2 ring-inset ring-blue-500">
<!-- two rings: an outer focus ring and an inner border-like ring (v4 only) -->
<button class="inset-ring inset-ring-gray-950/10 focus-visible:ring-2 focus-visible:ring-blue-500">Use inset-ring for a subtle inner edge on cards and buttons, and keep ring for focus. Like ring, inset-ring on its own is 1px in the current color.
Find what the upgrade tool cannot see
The upgrade tool scans your templates. It cannot rewrite classes assembled in JavaScript (`shadow-${size}`), stored in a database or CMS, or kept in files it does not scan. Search for them with ripgrep (rg):
# Old directives and config helpers
rg -n '@tailwind|resolveConfig|theme\(colors|theme\(screens' src
# The -sm names that now render one size larger
rg -n '\b(shadow|drop-shadow|blur|backdrop-blur|rounded)-sm\b' src
# outline-none, now really "none"
rg -n 'outline-none' src
# Removed opacity utilities
rg -n '\b(bg|text|border|divide|ring|placeholder)-opacity-' src
# Old CSS variable shorthand and comma-separated arbitrary values
rg -n '\[--[a-zA-Z]' src
rg -n '(grid-cols|grid-rows|object)-\[[^\]]*,' src
# Transforms that no longer reset or animate
rg -n 'transform-none|transition-\[[^\]]*transform' src
# @apply inside component styles that may need @reference
rg -n '@apply' --glob '*.{vue,svelte,astro}' --glob '*.module.css' srcA bare ring or border without a color cannot be found reliably with a regex. Review focus states and bordered components visually instead.
A visual check before you merge
After the upgrade, open the pages that use the most components and check:
- Focus states. Tab through a form: rings should be the width and color you expect, and focus must stay visible in forced colors mode.
- Borders and dividers. Look for borders that turned dark.
- Cards and buttons. Small shadows and small radii are the most common visual change.
- Forms. Placeholder color, and the cursor on buttons.
- Dialogs. Modals built on
<dialog>that are no longer centered. - Stacked lists. Anything using
space-y-*with inline or hidden children. - Touch devices. Menus or tooltips that relied on hover.
Screenshot comparisons in your test suite catch most of these automatically. If you have Playwright set up, a few toHaveScreenshot() checks on key pages, taken on v3 before the upgrade, make this review fast; see reliable end-to-end testing with Playwright.
Questions that come up
Was ring-inset removed in Tailwind v4?
No. ring-inset still works in v4. The new inset-ring-* utilities are an addition: a second, inset ring that can be combined with a normal outer ring.
Why are my borders black after upgrading to Tailwind v4?
The default border color changed from gray-200 to currentColor, so a border without a color class takes the text color. Add a color, such as border-gray-200, or set a base style for the old default.
Does the upgrade tool fix every breaking change?
Most of the renames and the setup, yes. It cannot fix classes it cannot see (built in JavaScript or stored as content), and it cannot decide visual questions for you, such as whether a 1px ring is acceptable. Review the diff and the pages.
Why did my shadows get bigger?
Because shadow-sm in v4 is the old shadow. The scale moved down one step to make room for shadow-xs. Rename shadow-sm to shadow-xs to get the v3 look.
Can I stay on Tailwind v3?
Yes. v3.4 still works, and it is the right choice if you must support browsers older than Safari 16.4, Chrome 111 or Firefox 128. Plan the move when your browser support policy allows it.
Why do my buttons no longer show a pointer cursor?
v4's base styles use the browser default cursor for buttons. Add cursor-pointer where you want it, or restore it for all buttons with a base style.
Sources and docs
- Tailwind CSS upgrade guide, the official list of breaking changes
- Tailwind CSS releases on GitHub
- Tailwind docs: functions and directives, adding custom styles and box shadow, including
inset-ring - MDN:
forced-colorsmedia feature andhovermedia feature