Next.js Discord

Discord Forum

Ignore classes via. NextJS Module CSS

Answered
Japanese pilchard posted this in #help-forum
Open in Discord
Japanese pilchardOP
Is it possible to ignore certain classes in the NextJS Module CSS?

I have to ignore the .dark property.
Answered by Rose-breasted Grosbeak
See the first suggestion,

https://chatgpt.com/share/67946981-05a0-8011-83d7-8f9585d385a2

It probably wouldn't work in normal css modules (it didn't work for me, the last time I tried)

So much for AGI..
View full answer

10 Replies

Rose-breasted Grosbeak
Wdym by ignore?
@Rose-breasted Grosbeak Wdym by ignore?
Japanese pilchardOP
The current problem is that the parsed CSS looks like this:
.page-module__E0kJGG__description:where(.page-module__E0kJGG__dark, .page-module__E0kJGG__dark *) {
  color: var(--color-red-500);
}

But it should look like this:
.page-module__E0kJGG__description:where(.dark, .dark *) {
  color: var(--color-red-500);
}


This is important so that Tailwind V4 works completely with the ModuleCSS. And for this I would have to ignore the .dark properties somehow so that they are not parsed

Related to https://github.com/tailwindlabs/tailwindcss/issues/15814
Japanese pilchardOP
Push
Rose-breasted Grosbeak
See the first suggestion,

https://chatgpt.com/share/67946981-05a0-8011-83d7-8f9585d385a2

It probably wouldn't work in normal css modules (it didn't work for me, the last time I tried)

So much for AGI..
Answer
@Rose-breasted Grosbeak Oh this issue. I don't think it's possible in normal modules. I just added the selectors in the global css file, otherwise, checkout scss.
Japanese pilchardOP
I got it to work with the following code:

:global(.dark) .cool_text {
    @apply text-red-500;
}
The global tag means that the .dark is not parsed. It is a bit annoying this way, but I accept it
Japanese pilchardOP
I found out last night, but forgot to tell you here. Thanks for your help
Rose-breasted Grosbeak