Skip to content

shadcn/ui not working with Tailwind v4: six causes and fixes

Unstyled or transparent shadcn components on Tailwind v4 come from v3 leftovers: the old PostCSS plugin, @tailwind directives, hsl() wrappers, missing imports.

Updated 23 November 2026Tested with
  • shadcn 4.23.0
  • Tailwind CSS 4.3.5
  • Vite 8
  • React 19.3

When shadcn/ui components show up unstyled, transparent or half-styled on Tailwind CSS v4, the cause is nearly always a leftover from a v3 setup: an old PostCSS plugin, the old @tailwind directives, colours wrapped in hsl(), or a missing import. We broke a fresh shadcn 4.23 project on Tailwind 4.3.5 in each of these ways and wrote down what you see and how to fix it.

Start with the symptom that matches yours.

What you seeLikely cause
Build error about using tailwindcss as a PostCSS plugin1. The old PostCSS plugin
No Tailwind styles at all, no error2. v3 @tailwind directives
Buttons and cards have no background, text is fine3. hsl(var(--…)) around oklch values
Components from a package or another folder are unstyled4. Files Tailwind doesn't scan
Dialogs, sheets and accordions open without animation5. A missing import
Dark mode works on the page but not inside one section6. @theme without inline

1. The old PostCSS plugin

A project upgraded from v3 often still has tailwindcss in postcss.config.js. v4 refuses it outright:

Terminal
npm run buildIt looks like you're trying to use `tailwindcss` directly as a PostCSS plugin. The PostCSS plugin has moved to a separate package, so to continue using Tailwind CSS with PostCSS you'll need to install `@tailwindcss/postcss` and update your PostCSS configuration.

On Vite (including Astro and React Router), drop PostCSS for Tailwind and use the Vite plugin. It's what shadcn init -t vite sets up:

vite.config.tsTypeScript
import tailwindcss from "@tailwindcss/vite"import react from "@vitejs/plugin-react"import { defineConfig } from "vite" export default defineConfig({  plugins: [react(), tailwindcss()],})

On Next.js or anything else that runs PostCSS, install @tailwindcss/postcss and use that instead. autoprefixer can go: v4 handles prefixes itself.

postcss.config.mjsJavaScript
export default {  plugins: { "@tailwindcss/postcss": {} },}

2. v3 @tailwind directives

This one has no error. A stylesheet that starts with

src/index.cssCSS
@tailwind base;@tailwind components;@tailwind utilities;

compiles on v4 to 65 bytes: the licence comment and nothing else. Replace the three lines with one:

src/index.cssCSS
@import "tailwindcss";

3. hsl(var(--…)) around oklch values

shadcn/ui on v3 stored colours as bare HSL numbers (--primary: 222.2 47.4% 11.2%) and components wrapped them: hsl(var(--primary)). On v4 the CLI writes complete colours (--primary: oklch(0.205 0 0)) and uses them as they are.

Mix the two and the colour becomes invalid. We checked it in Chromium: hsl(var(--primary)) with an oklch value computes to rgba(0, 0, 0, 0), fully transparent. That's why buttons lose their fill while text stays readable.

Look for hsl(var( in your CSS and in any component you copied from an older project or tutorial, and remove the wrapper. In your theme, map the variables in @theme inline, not in a JavaScript config:

src/index.cssCSS
@theme inline {  --color-primary: var(--primary);  --color-primary-foreground: var(--primary-foreground);}

If your whole theme is still in HSL numbers, the shadcn docs' v4 upgrade page converts them; or regenerate the theme with npx shadcn@latest init --force in a branch and copy the new variables over.

4. Files Tailwind doesn't scan

v4 detects your source files on its own, and skips anything in .gitignore. That includes node_modules. In a monorepo, components in packages/ui are outside the app folder and may not be scanned either. The classes in those files are never generated.

We confirmed it with a package in node_modules that uses bg-fuchsia-700: no class until we added a @source line, relative to the CSS file:

apps/web/src/index.cssCSS
@import "tailwindcss";@source "../../../packages/ui/src";

5. A missing import

A v4 shadcn project starts its CSS with four imports. Two of them are easy to lose in a merge or an upgrade:

src/index.cssCSS
@import "tailwindcss";@import "tw-animate-css";@import "shadcn/tailwind.css";

tw-animate-css provides animate-in, fade-in-0 and the other animation classes. shadcn/tailwind.css comes from the shadcn package in your dependencies and defines the data-open: and data-closed: variants and the accordion keyframes. Remove it and the build still passes, but the variants match the wrong attribute. Details and the check are in shadcn animations not working.

6. @theme without inline

If you write the colour mapping as @theme { --color-primary: var(--primary); }, Tailwind puts --color-primary on :root and the utility reads that. A .dark class on a nested element changes --primary there, but --color-primary was already resolved on :root. In our test the nested element stayed white with plain @theme and turned black with @theme inline. Keep the inline keyword that shadcn writes.

A quick health check

The shadcn CLI can tell you what it thinks your project is:

Terminal
npx shadcn@latest infoProject  framework         Vite (vite)  tailwindVersion   v4  tailwindConfig    -  tailwindCss       src/index.css  importAlias       @

tailwindVersion v4 with no tailwindConfig is what you want. The version comes from the Tailwind package you actually have installed. If tailwindConfig names a file, an old tailwind.config.js is still in the project. v4 ignores it unless your CSS loads it with @config, so anything you change in it has no effect. Move its values into your CSS and delete it.

Questions

Do I need a tailwind.config.js for shadcn/ui on Tailwind v4?

No. Leave "config": "" in the tailwind section of components.json. Everything lives in your CSS file. See does Tailwind 4 have a config file.

Is tailwindcss-animate still needed?

No. shadcn/ui replaced it with tw-animate-css in March 2025. If you still have tailwindcss-animate, swap it and import tw-animate-css in your CSS.

Can I remove the shadcn package from dependencies?

Not while your CSS imports shadcn/tailwind.css. The CLI itself you can run with npx, but that stylesheet is read from node_modules/shadcn. npx shadcn@latest eject inlines it if you want the package gone.

Was this page helpful?

Still stuck? We answer every message ourselves. Write to us

This page is built from UI Pro parts: the docs article block (docs-quernly) with the code, terminal, install command, steps, contents and feedback components. They ship in the next UI Pro release; the install command and the contents rail are free.