Skip to content

Instantly share code, notes, and snippets.

@socheatsok78
Created November 10, 2021 10:30
Show Gist options
  • Save socheatsok78/432e0d765af93f3729564092368fb235 to your computer and use it in GitHub Desktop.
Save socheatsok78/432e0d765af93f3729564092368fb235 to your computer and use it in GitHub Desktop.
Get a callback when the user changes theme
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', ({matches: isDark}) => {
console.log('isDark', isDark)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment