Skip to content

Toggle Dark Mode #384

Closed Answered by ITSYV
jeffchown asked this question in Feature Requests
Oct 10, 2024 · 1 comments · 8 replies
Discussion options

You must be logged in to vote

@jeffchown One way is to add this to your tailwind conf:
module.exports = { darkMode: 'selector', ... }
See: https://fluxui.dev/docs/installation#using-dark-mode

After adding this, you can toggle a "dark" class on your html or body tag with Alpine.
At the FluxUI website they store a boolean with javascript in "darkMode" ("x-on:click="$store.darkMode.toggle()"). But you can do the same storing a session or cookie and retrieving this in your app layout file

For local dev, you could just add / remove "dark" to your html/body tags to switch between themes.

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@jeffchown
Comment options

@jeffchown
Comment options

@ITSYV
Comment options

@jeffchown
Comment options

@jeffchown
Comment options

Answer selected by jeffchown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants