How to use Tailwind v4 with Next CSS modules #17342
Unanswered
tylerclark
asked this question in
Help
Replies: 2 comments
-
Beta Was this translation helpful? Give feedback.
0 replies
-
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.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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