Dark mode change detection
Javascript
javascript
window.matchMedia('(prefers-color-scheme: dark)').addListener(({ matches }) => {
if (matches) {
console.log("dark theme");
} else {
console.log("light theme");
}
});
Hint: try toggling dark mode on and off and observe this website 😉