Reactive CSS's prefers-color-scheme ?
I want to detect CSS prefers-color-scheme's changed.
I can make a event listener like
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => {
const isDarkMode = e.matches
// Do something
})
But it doesn't looks like Solid way.
Is there more elegant way?1 Reply
Sorry I just found this one.
https://github.com/solidjs-community/solid-primitives/tree/main/packages/media#useprefersdark
Amazing!!
GitHub
solid-primitives/packages/media at main · solidjs-community/solid-p...
A library of high-quality primitives that extend SolidJS reactivity. - solid-primitives/packages/media at main · solidjs-community/solid-primitives