Closed janbarasek closed 3 years ago
Detect:
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { // dark mode }
To watch for changes:
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => { const newColorScheme = e.matches ? "dark" : "light"; });
Done:
Detect:
To watch for changes: