ui: [bug]: Shadcn not validating Tailwind CSS installation after Tailwind 4 update

Describe the bug

After the update to Tailwind CSS 4, the npx shadcn@latest init command fails to validate the Tailwind CSS installation due to the removal of the Tailwind config file. This prevents the proper initialization of Shadcn. It is recommended to update the installation documentation to reflect these changes.

Image

Affected component/components

N/A (This issue affects the initialization process rather than specific components)

How to reproduce

  1. Update Tailwind CSS to version 4.
  2. Run the command npx shadcn@latest init.
  3. Observe that the command fails to validate the Tailwind CSS installation.

Codesandbox/StackBlitz link

No response

Logs

✔ Preflight checks.
✔ Verifying framework. Found Vite.
✖ Validating Tailwind CSS.
✖ Validating import alias.

No Tailwind CSS configuration found at C:\Users\ranbi\OneDrive\Desktop\Portfolio website\client.
It is likely you do not have Tailwind CSS installed or have an invalid configuration.
Install Tailwind CSS then try again.
Visit https://tailwindcss.com/docs/guides/vite to get started.

No import alias found in your tsconfig.json file.
Visit https://ui.shadcn.com/docs/installation/vite to learn how to set an import alias.

System Info

- Operating System: Windows 11
- Node.js version: (v22.12.0)
- NPM version: (10.9.0)

Before submitting

  • I’ve made research efforts and searched the documentation
  • I’ve searched for existing issues

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 64
  • Comments: 51 (1 by maintainers)

Most upvoted comments

I’m actively working on this. There’s a bit of work here. We’re currently in a transition phase where we need to support both React 18 + Tailwind v3 and React 19 + Tailwind v3, along with all possible combinations.

I’ve made some headway and will share an update soon.

In the meantime, here’s how you can start using/testing Tailwind v4:

  1. Install Tailwind v3 and npx shadcn init.
  2. Add all components: npx shadcn add --all.
  3. Run the Tailwind upgrade: npx @tailwindcss/upgrade@next.

This will upgrade all components and primitives to Tailwind v4.

I’m a subscriber to the issue, so I can read all the messages, with all due respect, but the people who are screaming to fix this urgently, why don’t you do your own fork/PR? That’s the point of an opensource project, we’re already lucky enough to have a community pushing this project to the max, I’m sure they’re already looking at the problem, there’s no point in pressing them anymore/disturbing them…

Give them time to fix the problem, don’t forget that for most of them this is a project in addition to their main job.

This is urgent @shadcn

@shadcn urgently sort out this issue

@shadcn update the issue

use this cmd

npm install -D tailwindcss@3.4.0 postcss autoprefixer

mention (@3.4.0)

I’ve updated the cli to support Tailwind v4 and React 19. Please test and share your feedback in the following thread: https://github.com/shadcn-ui/ui/issues/6585

Nice! @shadcn, Thank you.

For others, be more patient, it won’t be one less version that will end your project, just follow the steps and be happy.

Just to be clear, this is just an issue with init and components that change the tailwind config (accordion, sidebar). You can quite easily have tailwind v4 running, create a tailwind.config.ts, and then run npx shadcn@latest init. Afterwards you will need to update the tailwind theme in global.css the way tailwind v4 now defines the config or add the config using @config "../../tailwind.config.js";

Check out the example repo for how the global.css should be setup: https://github.com/shadcn/app-tailwind-v4

use this cmd

npm install -D tailwindcss@3.4.0 postcss autoprefixer

mention (@3.4.0)

Yes It works, but it will not solve the issue with tailwind 4

if you are using js make sure adding jsconfig file in root folder with this content

{ “compilerOptions”: { “baseUrl”: “.”, “paths”: { “@/“: [”./src/”] } } }

The problem seems to be simple. I believe this Tailwind validation step looks for the following directives:

@tailwind base;  
@tailwind components;  
@tailwind utilities;  

I simply created a file src/assets/index.css with the content above and ran the command pnpm dlx shadcn@latest init, and it worked just fine.

An update needs to be made in this validation step to also consider @import "tailwindcss";.

I think a quick update is needed

facing the same issue with my hilla project, not sure what is the issue…i am using tailwindcssv4 just fine.

I found a temporary workaround for this issue when using Tailwind CSS v4. Simply add @import 'tailwindcss'; to your global.css file. This allows the Shadcn CLI to detect Tailwind CSS installation properly during the validation step. This works because, as @shadcn mentioned, the CLI specifically looks for @import “tailwindcss” to validate the Tailwind installation. After adding this line, you should be able to successfully run npx shadcn@latest init without the Tailwind CSS validation error. This is just a quick fix while waiting for the CLI to be updated to properly support Tailwind CSS v4’s new structure.

Image

I’m a subscriber to the issue, so I can read all the messages, with all due respect, but the people who are screaming to fix this urgently, why don’t you do your own fork/PR? That’s the point of an opensource project, we’re already lucky enough to have a community pushing this project to the max, I’m sure they’re already looking at the problem, there’s no point in pressing them anymore/disturbing them…

Give them time to fix the problem, don’t forget that for most of them this is a project in addition to their main job.

Yes, the issue will be resolved by @shadcn itself, and we should wait. Spreading panic in this manner is not appropriate.

@nshaikhinurov Interesting. Yes the cli looks for a `@import “tailwindcss”. Will take a look.

Here what I did!

Image

Copy the globals.css and replace it in your code https://github.com/shadcn/app-tailwind-v4/blob/main/app/globals.css

Then run this npx shadcn@latest init without the -d flag. This fixed mine.

In my own case, the solution was getting rid of the defaults flag. I kept getting a tailwind validation error with “npx shadcn@latest init -d” command. Running the same command without “-d” worked, you just have to set up installation preferences yourself.

I see an issue with the --defaults flag, when I add this flag in a nextjs project shadcn init I always get tailwind validation error

This should be fixed now. Is this still happening?

@shadcn I faced exactly the same issue when using a blank starter from payloadCMS, the issue arrises because when installing pnpm dlx shadcn init it requires a global.css file. In this case payload uses style.css, so just adding global.css fixed for me.

Image Image

Run this: npx @tailwindcss/upgrade and then retry 😃

I have used tailwind version 3.4.17 and that works for my vite + javascript project.

  1. npm create vite@latest
  2. npm install -D tailwindcss@3.4.17 postcss autoprefixer
  3. npx tailwindcss init -p
  4. In src/index.css, paste this:
@tailwind base;
@tailwind components;
@tailwind utilities;
  1. Update ‘content’ of the tailwind.config.js with this:

    content: ["./index.html", "./src/**/*.{ts,tsx,js,jsx}"],

  2. create a jsconfig.json file and paste this:

{
    "files": [],
    "references": [
      {
        "path": "./jsconfig.app.json"
      }
    ],
    "compilerOptions": {
      "baseUrl": ".",
      "paths": {
        "@/*": ["./src/*"]
      }
    }
  }
  1. create a jsconfig.app.json file and paste this:
{
    "compilerOptions": {
      // ...
      "baseUrl": ".",
      "paths": {
        "@/*": [
          "./src/*"
        ]
      }
      // ...
    }
}
  1. Run this command:

npm install -D @types/node

  1. Replace vite.config.js file with this code:
import path from "path"
import react from "@vitejs/plugin-react"
import { defineConfig } from "vite"

export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
})
  1. Run the CLI:

npx shadcn@latest init

same here

Here what I did!

Image

1.Make a index.css file in SRC directory

@tailwind base;
@tailwind components;
@tailwind utilities;

Paste above code into the index.css file

  1. npx shadcn@latest init

@yeshansachithak THANK YOU

@shadcn / EVERYONE

I think I see the main root of the issue, its kind of buried in some chats, but not too clear. Let me show you my fix and let me know if that does it for you all as well. Currently using tailwind v4+, still make sure you have your config files for both tailwind and postcss installed and setup before moving forward.

I had been installing, removing, and repeating the same to upload tailwind, postcss, … the works. I had my globals.css nested within one of my directories, I moved that to my root ( this worked for me ) and re-ran the npx shadcn@latest init command.

Finally that is what did it - at lease for me, idk if its ShadCDN or whatever gets it going under the hood, but this solution solved an hour of brain aneurisms.

Hope it works for you all.

@PedroPini Can you help me reproduce? The cli does not require a global.css file. It looks for any css file with the @import tailwindcss line.

Image

The problem seems to be simple. I believe this Tailwind validation step looks for the following directives:

@tailwind base;  
@tailwind components;  
@tailwind utilities;  

I simply created a file src/assets/index.css with the content above and ran the command pnpm dlx shadcn@latest init, and it worked just fine.

An update needs to be made in this validation step to also consider @import "tailwindcss";.

I can confirm this works with

"next": "15.2.0",
"react": "^19.0.0",

and using pnpm

thanks @ericksousa !

Facing this issue in my Next.js project

Oh my god YES, i’m facing this issue, hopefully we get the solution soon