Next.js Discord

Discord Forum

Tailwind Incorrectly trying to apply darkmode styles

Answered
Thrianta posted this in #help-forum
Open in Discord
ThriantaOP
I'm using tailwind with next 14 and when doing something applying something like dark:bg-slate-700 it will generate some weird style that doesn't work at all. How can I fix this?
Answered by Thrianta
so the only solution is using data-theme=“dark” on the top layer instead of just a class
View full answer

7 Replies

Those css styles are processed before used, meaning you dont generate more css than necessary iirc.

Try #Tailwind.
is there a chance that op is using module css for tailwind and that is messing with it.. idk tho
Hmm could be
I guess either way some basic code is necessary
ThriantaOP
yeah that was the case
nextjs gets its hands on it after tailwind and messes it up
ThriantaOP
so the only solution is using data-theme=“dark” on the top layer instead of just a class
Answer