How to use Tailwind v4 with Next CSS modules #17342
Replies: 3 comments 2 replies
-
Beta Was this translation helpful? Give feedback.
-
Got it to work following: https://tailwindcss.com/docs/compatibility#explicit-context-sharing You need to @reference "../app.css";
button {
@apply bg-blue-500;
} |
Beta Was this translation helpful? Give feedback.
-
Hello! If you'll excuse me, I was doing some tests and, fortunately, I discovered that @reference can receive 'tailwindcss' and work normally. If you want to test this instead of passing the path to the globals.css file @reference "tailwindcss"; If it works, you won't need to keep passing the path throughout the file |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I was trying to do a few things:
SampleComponent.tsx
) in Next with a module stylesheet to scope the CSS (SampleComponent.module.css
)SampleComponent.tsx
, I want to give unique class names and then reference those class names in the stylesheet. Not using Tailwind classes in the component but rather in the stylesheet. For example<div className="container">
SampleComponent.module.css
I would have the class.container { @apply rounded-full w-14 h-14 flex items-center justify-center bg-white hover:bg-gray-100 }
I was doing this and not using inline TW class names because I am embedding this component in other websites so being able to have an external stylesheet was important. Anyway! When I have the file called
SampleComponent.module.css
it wouldn't load the Next website. If I renamed it toSampleComponent.css
it was able to load.This is fine I guess but I really want to understand what is happening that causes this issue. Is this Webpack and Tailwind JIT compiler having issues? Is there a special config that I need to have on my side? I just want to be a better advanced Tailwind user as this seems pretty basic.
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions