Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using route group in NextJS 13 stops tailwind from working

In my NextJS 13 app, Tailwind classes stop being applied when I move page.tsx/layout.tsx from the root of my app directory into a (main) directory (also in the root of my app directory). I imagine there is some config somewhere that is becoming invalidated when I use the route group, but I'm not sure what it is.

This is my tailwind.config file:

import type { Config } from 'tailwindcss'

const config: Config = {
  content: [
    './src/pages/**/*.{js,ts,jsx,tsx,mdx}',
    './src/components/**/*.{js,ts,jsx,tsx,mdx}',
    './src/app/**/*.{js,ts,jsx,tsx,mdx}',
  ],
  theme: {
    extend: {
      backgroundImage: {
        'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
        'gradient-conic':
          'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',
      },
    },
  },
  plugins: [],
}
export default config

like image 933
Sylith Avatar asked Nov 01 '25 18:11

Sylith


2 Answers

In my case, I created a UI component in another folder and forgot to add that to the (content) section in tailwind.config. but if it is not your case check this solution too which was mentioned in tailwind GitHub issues:

content: [
'./src/app/(group-name)/**/*.{js,ts,jsx,tsx,mdx}',
]
like image 62
Amirreza Pourkairm Avatar answered Nov 03 '25 07:11

Amirreza Pourkairm


you need to import the globals.css where you have the directives:

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

into all the root layouts of the new route groups. You can just have 1 global css in the root directory

like image 30
Husky931 Avatar answered Nov 03 '25 09:11

Husky931



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!