data-bs-theme auto #37727
-
Hi 👋 I've some difficulty implementing proper dark mode switcher:
I've tried to not set anything at all but it defaults to "light". The problem is, if user is using dark mode on device, it doesn't respect that. Then I've tried to get user's preferred mode in JS and set proper them, it works but there is a flicker on page load of user prefer dark. On getbootstrap.com home page, you're using data-bs-theme=auto, but It's not defined in bootstrap.css. Am I doing it wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi @FaridAghili. |
Beta Was this translation helpful? Give feedback.
-
Hi 👋 I have a question. How can i when user selects "light" or "dark" , I set data-bs-theme="light" or "dark" on html tag ? I'm a student and somehow I couldn't find anywhere how to edit the data-bs-theme tag. |
Beta Was this translation helpful? Give feedback.
Hi @FaridAghili.
IDK if you've seen it but you can reuse our
color-modes.js
that is used in our docs to handle the switcher. Or at least you should be able to take inspiration from it.