Tailwind classes have no effect in a Next.js app
Tailwind classes are in the markup but nothing is styledShort answer
The page loads but Tailwind classes do nothing when the generated CSS never reaches the page. Usual reasons: globals.css is not imported in the root layout, v3 directives are used with v4 installed (or the reverse), the PostCSS plugin is wrong for the version, or v3 content paths miss your folders.
Fix it fast
1Find out which cause you have
Find out which major version you have installed, because v3 and v4 are set up differently.
npm ls tailwindcss @tailwindcss/postcss cat postcss.config.* app/globals.css | head -202Match what you see, then jump to its fix
- 1
No Tailwind styles at all, even for simple classesglobals.css is not imported in the root layoutFix - 2
The CSS file starts with @tailwind base; and tailwindcss is version 4v3 directives with Tailwind v4 installedFix - 3
Tailwind v4 with plugins: { tailwindcss: {} } in postcss.configThe PostCSS plugin is wrong for the installed versionFix - 4
Tailwind v3; classes in some folders work and in others do notv3 content paths do not cover your foldersFix - 5
Custom theme values from tailwind.config.js do not apply in v4tailwind.config.js is ignored in v4Fix
- 1
What does the error look like?
Tailwind classes are in the markup but nothing is styledStyles from Tailwind never reach the page after install
Cause 1 of 5
globals.css is not imported in the root layout
1Check
The stylesheet that holds the Tailwind import must be imported by the root layout.
grep -n "globals.css" app/layout.*2Fix
Import it at the top of the root layout.
// app/layout.tsx
import './globals.css'3Verify
Reload; a class like text-3xl now changes the page.
npm run devConfirmed by nextjs.org
Cause 2 of 5
v3 directives with Tailwind v4 installed
1Check
In v4 you import Tailwind with a normal CSS @import, not the @tailwind directives.
head -5 app/globals.css2Fix
Replace the three directives with one import.
/* app/globals.css */
@import "tailwindcss";3Verify
Restart the dev server and check a utility class.
npm run devConfirmed by tailwindcss.com
Cause 3 of 5
The PostCSS plugin is wrong for the installed version
1Check
In v3 the tailwindcss package is the PostCSS plugin. In v4 the plugin lives in @tailwindcss/postcss.
cat postcss.config.*2Fix
For v4, install the plugin and use it.
npm install tailwindcss @tailwindcss/postcss postcss
// postcss.config.mjs
const config = {
plugins: {
"@tailwindcss/postcss": {},
},
};
export default config;3Verify
Restart the dev server.
npm run devConfirmed by tailwindcss.com
Cause 4 of 5
v3 content paths do not cover your folders
1Check
The content array in tailwind.config.js lists where Tailwind looks for class names.
cat tailwind.config.js2Fix
Add every folder that holds components.
module.exports = {
content: [
'./app/**/*.{js,ts,jsx,tsx,mdx}',
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
'./components/**/*.{js,ts,jsx,tsx,mdx}',
],
theme: { extend: {} },
plugins: [],
}3Verify
Restart the dev server and recheck the missing class.
npm run devConfirmed by nextjs.org
Cause 5 of 5
tailwind.config.js is ignored in v4
1Check
v4 no longer detects JavaScript config files automatically.
ls tailwind.config.*2Fix
Load it from your CSS file with @config, or move the settings into CSS.
/* app/globals.css */
@import "tailwindcss";
@config "../tailwind.config.js";3Verify
Restart and check a custom theme class.
npm run devConfirmed by tailwindcss.com
How do I stop it coming back?
- Follow one setup guide for the exact major version you install.
- Restart the dev server after editing PostCSS or Tailwind config.
- Pin the Tailwind 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
Next.js fails with Cannot find module 'tailwindcss'
Error: Cannot find module 'tailwindcss'
Next.js loads Tailwind through PostCSS, so the error means the package named in postcss.config is not installed where the build runs.
3 causes, each with a fixWeb apps
A custom Tailwind color does not apply to the element
text-primary works in one component but not in another
Tailwind only creates a color class when it finds the whole class name in your source, and in v4 only when the color is defined in the --color-* theme namespace.
4 causes, each with a fixWeb apps
There is no tailwind.config.js after installing Tailwind 4 and HeroUI in Next.js
HeroUI components render unstyled
Nothing is broken: Tailwind CSS 4 is configured in CSS and no longer creates tailwind.config.js.
3 causes, each with a fixWeb 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 fixWeb apps
A shadcn/ui Dialog stays open after the form is submitted
Form submits and the data saves, but the modal remains on screen
A shadcn Dialog is a Radix dialog.
3 causes, each with a fixWeb apps
Tailwind CSS 4 build fails on @apply in a Next.js project
Cannot apply unknown utility class
Tailwind 4 only knows its utilities in a stylesheet that imports Tailwind.
2 causes, each with a fix