JavaScript erkennen den dunklen Modus
const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
Batman
const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
console.log(isDarkMode) // Result: True or False
const darkTheme = window.matchMedia("(prefers-color-scheme: dark)");
if (darkTheme.matches) {
document.documentElement.classList.add("dark");
} else {
document.documentElement.classList.remove("dark");
}