Created
November 10, 2021 10:30
-
-
Save socheatsok78/432e0d765af93f3729564092368fb235 to your computer and use it in GitHub Desktop.
Get a callback when the user changes theme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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