Tailwind CSS v4 Common Errors and Fixes
October 2, 2026 | 10 min read | Tailwind CSS
By Syed · Frontend Engineer & Creator of UITweak
Tailwind CSS v4 rebuilt the framework from the ground up: CSS-first configuration, a new engine, and renamed utilities. That means upgrades break in confusing ways, and the errors rarely explain themselves. This guide collects the mistakes developers hit most often after moving to v4, with the exact fix for each one.
Shortcut: inspect your generated utilities and theme tokens visually in our free Tailwind Visualizer. For the full theming system behind these fixes, see our Tailwind v4 @theme guide.
1. bg-opacity-* Does Nothing
Symptom: bg-black bg-opacity-50 renders a fully opaque background. No error, just silently wrong.
Why: v4 removed the bg-opacity-* utilities. Opacity is now handled with the slash modifier and native color-mix under the hood.
Fix: replace every bg-opacity-* with the modifier syntax:
<!-- v3 (broken in v4) -->
<div class="bg-black bg-opacity-50">...</div>
<!-- v4 fix -->
<div class="bg-black/50">...</div>2. bg-gradient-to-* Stopped Working
Symptom: bg-gradient-to-r produces no gradient at all.
Why: v4 renamed gradient direction utilities to match the CSS spec: bg-linear-to-r. The old names were removed, not deprecated with a warning.
Fix: rename across your project:
<!-- v3 (broken in v4) -->
<div class="bg-gradient-to-r from-indigo-500 to-pink-500">...</div>
<!-- v4 fix -->
<div class="bg-linear-to-r from-indigo-500 to-pink-500">...</div>The same rename applies to bg-gradient-to-l, -t, -b, and the diagonal variants. A project-wide find and replace of bg-gradient-to- with bg-linear-to- catches all of them.
3. "@apply Cannot Be Used" / Unknown Utility Errors
Symptom: your CSS file throws errors like Cannot apply unknown utility class for utilities that clearly exist.
Why: in v4, @apply in a plain CSS file cannot see your utilities unless that file imports Tailwind. The classic setup imported Tailwind in one entry file and used @apply in others, which no longer works.
Fix: add the reference import at the top of any CSS file that uses @apply:
/* Add this to the top of every CSS file using @apply */
@reference "tailwindcss";
.card {
@apply rounded-2xl bg-white p-6 shadow-lg;
}@reference makes your theme and utilities visible to that file without emitting duplicate CSS. If you defined custom utilities in v3 with a plugin, convert them to the v4 @utility directive instead.
4. Custom Theme Values Are Ignored
Symptom: bg-brand or text-brand generate nothing, even though you defined the color.
Why: v4 moved configuration from tailwind.config.js into CSS with @theme. A leftover v3 config file is silently ignored by the v4 engine.
Fix: define tokens in CSS:
/* v4: theme lives in CSS, not tailwind.config.js */
@import "tailwindcss";
@theme {
--color-brand: #6d28d9;
--font-display: "Sora", sans-serif;
}
<!-- now these work -->
<div class="bg-brand font-display">...</div>5. dark: Variant Follows the OS Instead of Your Toggle
Symptom: your dark mode toggle adds a dark class, but dark:bg-gray-900 never applies.
Why: v4 defaults the dark: variant to prefers-color-scheme. The v3 darkMode: "class" setting does not exist anymore.
Fix: register a custom variant in your CSS:
@import "tailwindcss";
/* v4 replacement for darkMode: "class" */
@custom-variant dark (&:where(.dark, .dark *));After this, toggling the dark class on <html> works exactly like v3 did.
6. Nothing Works: Wrong Framework Integration
Symptom: no utilities are generated at all, or styles work in dev but vanish in the build.
Why: v4 needs its framework plugin. The single most common setup mistake, especially with Astro, Next.js, and Vite, is missing or misconfigured integration: the old PostCSS-only setup or a v3-style config quietly produces nothing.
Fix: install and register the v4 plugin for your setup. For Vite:
// vite.config.js
import tailwindcss from "@tailwindcss/vite";
export default {
plugins: [tailwindcss()],
};Then make sure your CSS entry contains @import "tailwindcss"; and that no stale v3 tailwind.config.js is confusing the build.
7. Borders Turned Black Out of Nowhere
Symptom: after upgrading, all your border utilities render with dark borders you never asked for.
Why: v4 changed the default border color from gray-200 to currentColor to match browser defaults.
Fix: either set an explicit border color where it matters, or restore the old default in your theme:
@theme {
--default-border-color: var(--color-gray-200);
}Quick Diagnosis Checklist
- Search the project for
bg-opacity-and replace with the slash modifier. - Search for
bg-gradient-to-and rename tobg-linear-to-. - Every CSS file using
@applyneeds@reference "tailwindcss";at the top. - Theme values belong in
@themein CSS, not intailwind.config.js. - Class-based dark mode needs the
@custom-variant darkline. - Verify the
@tailwindcss/vite(or framework) plugin is installed and registered.
# Expansion draft: tailwind-v4-common-errors-fixes-guide
8. Shadows, Corners, and Blurs Shifted Down a Size
**Symptom:** after upgrading, shadows look subtler than before, corners slightly tighter, blurs slightly weaker. No errors. Everything renders, just not quite like the design.
**Why:** v4 inserted a new smallest step into several scales and shifted the old names down. shadow-sm is now shadow-xs. Bare shadow is now shadow-sm. The same shift hit rounded (rounded-sm became rounded-xs, bare rounded became rounded-sm) and blur (blur-sm to blur-xs, bare blur to blur-sm, including the backdrop- variants).
**Fix:** this one is a careful find-and-replace, not a logic change:
<!-- v3 -->
<div class="rounded shadow-sm blur-sm">...</div>
<!-- v4, same visuals -->
<div class="rounded-sm shadow-xs blur-xs">...</div>The reason this deserves its own entry: unlike bg-gradient-to-r, which breaks loudly, the old names still exist in v4 and map to different values. Your build succeeds, your tests pass, and the design is quietly wrong. I have seen this ship to production more than once because nobody diffed screenshots. If your team does visual regression testing, this is the upgrade that justifies it. If not, at least screenshot the key pages before and after the upgrade and compare them side by side.
9. outline-none No Longer Hides the Outline
**Symptom:** you migrated outline-none to outline-hidden per the rename list, or you kept outline-none and now focus rings behave differently than you expected.
**Why:** in v3, outline-none did not actually remove the outline. It set a transparent 2px outline with a 2px offset, so the element still took up outline space and stayed visible in Windows high-contrast mode. v4 renamed that behavior to outline-hidden and gave outline-none its literal meaning: outline-style: none, the outline is truly gone.
**Fix:** decide what you actually wanted:
<!-- old v3 behavior: invisible but space-reserving outline -->
<button class="outline-hidden">...</button>
<!-- genuinely no outline (use with a custom :focus-visible style) -->
<button class="outline-none focus-visible:ring-2">...</button>In practice, most outline-none usages in v3 wanted outline-hidden semantics, which is why the upgrade tool maps it that way. But if you are removing outlines, pair it with a visible focus alternative. Keyboard users depend on it, and outline-style: none with no replacement is an accessibility regression, not a cleanup.
10. The Default Ring Got Thinner and Lost Its Color
**Symptom:** focus rings and decorative rings look anemic after the upgrade, or they picked up the text color.
**Why:** two defaults changed at once. The bare ring utility went from 3px to 1px, and the default ring color changed from a blue to currentColor, matching the border default change from section 7 of the main guide.
**Fix:** restore the old look explicitly where it matters:
<!-- v3 ring appearance -->
<button class="ring-3 ring-blue-500">...</button>I prefer being explicit here rather than restoring the old defaults globally. The 1px currentColor ring is a reasonable default for most new work, and blanket-restoring v3 defaults just postpones learning the new scale. Fix the instances you can see, leave the default alone.
The Upgrade Tool: What It Fixes and What It Misses
The official upgrade tool (npx @tailwindcss/upgrade) automates most of this guide. Run it on a clean branch, review the diff, and it will rewrite renamed utilities, convert tailwind.config.js into @theme tokens, and swap the old @tailwind directives for @import "tailwindcss". For a typical project it handles the mechanical 80 percent in minutes. Run it before you start fixing things by hand.
Then handle what it cannot see, because the tool only rewrites what it can read as literal text:
- **Dynamically built class names.**
shadow-${size}in a template literal is invisible to the codemod, exactly as it is invisible to the scanner. These need the lookup-map treatment from the production-styles guide, and the upgrade tool will not flag them. - **
@applyin files outside the pipeline.** The tool migrates your entry stylesheet. A CSS module with@apply bg-gradient-to-rthat was already broken stays broken, just with a v4 rename inside it. - **Visual shifts, not breakages.** Sections 8 through 10 above are renames where the old class still compiles to something. The tool rewrites them, but only where it finds literal strings. Anything generated at runtime keeps the old value silently.
- **Semantic choices.** The tool maps
outline-nonetooutline-hiddenmechanically. Whether you actually wanted the outline gone is a decision only a human on your team can make.
My workflow: run the tool, review every hunk of the diff (it is usually smaller than you fear), then do a visual pass over the ten most-visited pages. The diff review catches logic errors. Only the visual pass catches the quiet shifts.
Frequently Asked Questions
Is Tailwind v4 a breaking upgrade from v3?
Mostly mechanical, not conceptual. Your utility classes largely work the same; the breaks are in configuration (CSS-first now), renamed utilities, and the integration plugin. The checklist above covers the vast majority of upgrade pain.
Can I keep tailwind.config.js in v4?
The v4 engine ignores it. Move every custom value into @theme in your CSS. You can keep the file around during migration, but nothing reads it.
Why does @apply say my utility does not exist?
The CSS file cannot see Tailwind's utilities. Add @reference "tailwindcss"; at the top of that file and the error goes away.
Next step: once the errors are gone, learn the system behind the fixes in our Tailwind v4 @theme guide, and inspect your generated utilities in the free Tailwind Visualizer.