Replies: 5 comments 17 replies
-
Related:
Based on the linked documentation, I would structure your code like this in v4: @import "tailwindcss";
@custom-variant dark (&:where(.dark, .dark *));
@custom-variant sky-light (&:where(.sky-light, .sky-light *));
@custom-variant sky-dark (&:where(.sky-dark, .sky-dark *));
@theme {
--color-app-background: hsl(210 20% 98%);
}
@layer theme {
:root, :host {
@variant dark {
--color-app-background: hsl(216 13% 15%);
}
@variant sky-light {
--color-app-background: hsl(210 20% 98%);
}
@variant sky-dark {
--color-app-background: hsl(216 13% 15%);
}
}
} Tip I created another playground using @crswll's approach that better demonstrates using themes on the "root" element (since the playground doesn't allow direct manipulation of the Of course, you can use OKLCH colors instead of HSL colors - I just didn't feel like converting them. Themes:
I don't want to repeat myself too much since there are already plenty of write-ups about this on GitHub and Stack Overflow. In v4, the JS config was removed, so to switch the |
Beta Was this translation helpful? Give feedback.
-
Your suggestion does not show how it addresses the following:
How would that work with what you suggested? |
Beta Was this translation helpful? Give feedback.
-
Anyone got some insights? |
Beta Was this translation helpful? Give feedback.
-
@spacecat I came looking for a similar answer, and the suggestion above works. You didn't test the solution in the tailwind playground. It is actually what you want. This is the HTML structure. It uses one class, ![]() |
Beta Was this translation helpful? Give feedback.
-
So I have this and it works fine in TailwindCSS v4:
Now I'm trying to use
@adamwathan Could you please share some insight regarding this topic? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In my Next.js 15/TailwindCSS v3 app i have 11 themes. 5 dark ones and 6 light ones. I'm planning on upgrading to TailwindCSS v4.
The structure looks likes this:
How would this look in v4?
Something like this?
Should I use
@layer theme
or@layer base
to put:root
,.dark
,.sky_light
,.sky_dark
, etc ?Is nesting variables in properties in
@layer theme
legal?Beta Was this translation helpful? Give feedback.
All reactions