Created
June 25, 2025 23:08
-
-
Save sombriks/c2e5a7710a6830695d4b688e3a598baf to your computer and use it in GitHub Desktop.
bootstrap color scheme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// <script defer src="base.js"></script> | |
const setTheme = e => { | |
if (e.matches) document.querySelector(":root").dataset.bsTheme = "dark"; | |
else document.querySelector(":root").dataset.bsTheme = "light"; | |
} | |
const matchMedia = window.matchMedia('(prefers-color-scheme: dark)'); | |
matchMedia.onchange = setTheme; | |
setTheme(matchMedia); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment