mirror of
https://github.com/YunoHost/pepettes.git
synced 2024-09-03 20:06:20 +02:00
13 lines
435 B
JavaScript
13 lines
435 B
JavaScript
// Set theme to the user's preferred color scheme
|
|
function updateTheme() {
|
|
const colorMode = window.matchMedia("(prefers-color-scheme: dark)").matches ?
|
|
"dark" :
|
|
"light";
|
|
document.querySelector("html").setAttribute("data-bs-theme", colorMode);
|
|
}
|
|
|
|
// Set theme on load
|
|
updateTheme()
|
|
|
|
// Update theme when the preferred scheme changes
|
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', updateTheme)
|