Skip to content

Conversation

@rubas
Copy link
Contributor

@rubas rubas commented Jul 2, 2025

The Theme Switcher root.html.heex uses the data-theme attribute to toggle between light/dark themes.
Tailwind's dark: variant expects per default a class="dark" though.

This custom variant makes Tailwind's dark: work with data-theme="dark".

@custom-variant dark (&:where([data-theme=dark], [data-theme=dark] *));

Without this, the dark: utility will not work, even DaisyUI themes switch correctly.

👉 Reference: https://tailwindcss.com/docs/dark-mode#using-a-data-attribute

@Gazler
Copy link
Member

Gazler commented Jul 3, 2025

This is how daisyUI recommends doing it too
https://daisyui.com/docs/themes/#how-to-apply-tailwinds-dark-selector-for-specific-themes

@SteffenDE SteffenDE merged commit 92b9389 into phoenixframework:main Jul 7, 2025
6 checks passed
@SteffenDE
Copy link
Contributor

Thank you! 🙌🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants