Обнаружение System Dark Mode CSS CSS
// toggle
const darkTheme = window.matchMedia("(prefers-color-scheme: dark)");
if (darkTheme.matches) {
document.documentElement.classList.add("dark");
} else {
document.documentElement.classList.remove("dark");
}
Dead Dormouse