Skip to content

Dark mode class toggle not reflecting styles in Tailwind CSS v4 #18207

Answered by wongjn
DARK7177 asked this question in Help
Discussion options

You must be logged in to vote

It seems like you're trying to use a dark class name to toggle between dark and light mode. By default, Tailwind uses the prefers-color-scheme media query. So, to use a class name toggle instead, you'd need to configure Tailwind to do so:

-@import 'tailwindcss'
+@import 'tailwindcss';

+@custom-variant dark (&:where(.dark, .dark *));

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@DARK7177
Comment options

@DARK7177
Comment options

Answer selected by DARK7177
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #18206 on June 02, 2025 18:02.