Fix guides · Cursor, Claude Code, Bolt, Windsurf, v0 ·
Fix "trying to use tailwindcss directly as a PostCSS plugin"
It 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.
This error means your project installed Tailwind CSS v4, but the PostCSS config is still written for Tailwind v3. In v4 the PostCSS plugin moved to its own package, @tailwindcss/postcss. It usually happens after npm install pulled the latest Tailwind into a project (or AI template) set up for v3. Either finish the move to v4 or pin Tailwind to v3. Don't mix the two.
Common causes – and how to tell which one you have
1. Tailwind v4 installed with a v3 PostCSS config
How to tell: npm ls tailwindcss shows 4.x, and postcss.config.js/mjs lists tailwindcss: {} (and often autoprefixer: {}) as plugins.
Fix: Install @tailwindcss/postcss and change postcss.config to plugins: { '@tailwindcss/postcss': {} }. Remove autoprefixer and postcss-import from the config; v4 handles both.
2. An AI tool or tutorial generated a v3 setup
How to tell: The project was just created or the AI added Tailwind with npx tailwindcss init -p and a tailwind.config.js, but npm installed the latest version (v4).
Fix: Either follow the v4 setup (PostCSS plugin or @tailwindcss/vite, @import "tailwindcss" in CSS) or install tailwindcss@3 to match the generated v3 setup.
3. The CSS still uses v3 directives
How to tell: After fixing the plugin the build runs, but no Tailwind classes apply. The main CSS file still starts with @tailwind base; @tailwind components; @tailwind utilities;.
Fix: Replace those three lines with @import "tailwindcss";. If you need your old tailwind.config.js (custom colors, fonts), add @config "../tailwind.config.js"; below the import or move the values into an @theme block.
4. A dependency update upgraded Tailwind
How to tell: It worked yesterday. package.json says "tailwindcss": "latest" or "^3" was changed, or the lock file was deleted and reinstalled.
Fix: Pin the version you want ("tailwindcss": "^3.4" or the v4 setup above), commit the lock file, and reinstall.
How to fix it
- Check which Tailwind you have: run npm ls tailwindcss. Version 4.x causes this error with an old config.
- Decide: upgrade to v4 (recommended for new projects) or stay on v3 (safer for a big existing project).
- For v4 with PostCSS: npm install -D @tailwindcss/postcss, and set postcss.config to plugins: { '@tailwindcss/postcss': {} }.
- For v4, replace @tailwind base; @tailwind components; @tailwind utilities; in your CSS with @import "tailwindcss";.
- For a Vite project you can use the @tailwindcss/vite plugin in vite.config instead of PostCSS.
- To stay on v3 instead: npm install -D tailwindcss@3 and keep the old config. Restart the dev server either way.
Using Lovable, Bolt or v0?
In Bolt, v0 or Lovable, paste the full error and say: "Tailwind v4 is installed. Update the setup to v4 (@tailwindcss/postcss or @tailwindcss/vite, @import 'tailwindcss' in the CSS) and keep my custom theme colors." If the project is large, ask it to pin tailwindcss@3 instead.
Using Cursor, Claude Code or Windsurf?
Ask Cursor or Claude Code to check the Tailwind version, then follow the official Tailwind upgrade guide for that setup (Next.js uses PostCSS, Vite can use @tailwindcss/vite). Have it carry over custom theme values and run the build, then check one page visually.
The “fix” to avoid
Agents sometimes install @tailwindcss/postcss but leave tailwindcss and autoprefixer in the PostCSS config, or keep the @tailwind directives. The error changes or styles silently disappear. Do the whole v4 setup, or stay on v3 completely.
Copy-paste fix prompt for your AI coding tool
Paste this into Cursor, Claude Code, Lovable or Bolt:
My build fails with "It looks like you're trying to use tailwindcss directly as a PostCSS plugin". Check the installed Tailwind version (npm ls tailwindcss) and the PostCSS config. If it's v4: install @tailwindcss/postcss, set postcss.config plugins to { '@tailwindcss/postcss': {} }, remove tailwindcss and autoprefixer from it, replace the @tailwind directives in the main CSS with @import "tailwindcss", and load an existing tailwind.config.js with @config if we still need it. Don't mix v3 and v4 setup. Restart the dev server, run the build, and check that styles still apply on the main page.
Questions people ask
Should I upgrade to v4 or stay on v3?
For a new or small project, upgrade: it's a few config lines. For a big project with many custom plugins or a large tailwind.config.js, pin v3 now and upgrade later with the official upgrade tool (npx @tailwindcss/upgrade).
Do I still need autoprefixer?
Not with Tailwind v4. It adds vendor prefixes itself, so you can remove autoprefixer from the PostCSS config.
Where did tailwind.config.js go?
v4 doesn't load it automatically. You configure the theme in CSS with @theme, or load the old file with @config.
Official documentation
- Tailwind CSS: Upgrade guide (v3 to v4)
- Tailwind CSS: Installing with PostCSS
- Tailwind CSS: Installing with Vite