Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

There is no tailwind.config.js after installing Tailwind 4 and HeroUI in Next.js

Errortailwind.config.js not found in a new Next.js project

Short answer

Nothing is broken: Tailwind CSS 4 is configured in CSS and no longer creates tailwind.config.js. With HeroUI v3 you add two imports to globals.css, tailwindcss first and @heroui/styles second. If you still need a JS config, load it yourself with @config.

  • Applies to Tailwind CSS 4, HeroUI 3, Next.js 15, React 19
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check which Tailwind version you have and what your global stylesheet imports. These two facts decide the cause.

    npm ls tailwindcss
    head -5 app/globals.css
  2. 2Match what you see, then jump to its fix

    1. 1npm ls shows tailwindcss 4.x and the file was never generatedTailwind CSS 4 has no config file by designFix
    2. 2Tailwind classes work but HeroUI components look unstyledHeroUI styles are not imported, or are imported in the wrong orderFix
    3. 3You migrated from Tailwind 3 and custom colors or plugins from tailwind.config.js stopped workingAn old JS config is not loadedFix

What does the error look like?

  • tailwind.config.js not found in a new Next.js project
  • HeroUI components render unstyled

Cause 1 of 3

Tailwind CSS 4 has no config file by design

1Check

In version 4 configuration lives in CSS (@theme, @plugin, @source), and PostCSS uses the @tailwindcss/postcss plugin. A JS config is no longer detected automatically.

cat postcss.config.mjs
grep -n "@import" app/globals.css

2Fix

Do not create the file. Use the Tailwind 4 setup: the PostCSS plugin and one import in the stylesheet.

npm install tailwindcss @tailwindcss/postcss postcss

// postcss.config.mjs
const config = { plugins: { "@tailwindcss/postcss": {} } };
export default config;

/* app/globals.css */
@import "tailwindcss";

3Verify

Start the dev server and use a utility class such as text-3xl on a heading.

npm run dev

Confirmed by tailwindcss.com

Did this fix it?

Cause 2 of 3

HeroUI styles are not imported, or are imported in the wrong order

1Check

HeroUI v3 needs React 19 and Tailwind 4, and its setup is two CSS imports. It does not use a tailwind.config.js. The order matters: tailwindcss must come first.

head -5 app/globals.css

2Fix

Install the packages and put both imports in your main stylesheet, in this order.

npm i @heroui/styles @heroui/react

/* app/globals.css */
@import "tailwindcss";
@import "@heroui/styles";

3Verify

Reload the page and render a HeroUI button; it should have its theme styling.

npm run dev

Confirmed by heroui.com

Did this fix it?

Cause 3 of 3

An old JS config is not loaded

1Check

A config file is still supported for backward compatibility, but Tailwind 4 does not find it by itself.

ls tailwind.config.*

2Fix

Load it from the stylesheet with @config, after the Tailwind import, or move its values into @theme over time.

@import "tailwindcss";
@config "../tailwind.config.js";

3Verify

Rebuild and check that a custom value from the config applies.

npm run dev

Confirmed by tailwindcss.com

Did this fix it?

How do I stop it coming back?

  • Read the HeroUI version you install: v3 steps differ from the v2 guides still found online.
  • Keep Tailwind configuration in CSS for new code and avoid mixing both styles.
  • Pin tailwindcss to a major version in package.json.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Web apps

Hydration failed after adding next-themes dark mode

Console reports a server and client mismatch on the html element

next-themes changes the html element and knows the theme only in the browser, so server HTML and client HTML differ.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.