Simple Dark mode detector
This file contains 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
let matched = window.matchMedia('(prefers-color-scheme: dark)').matches; | |
if(matched) { | |
console.log('User has Dark mode'); | |
} | |
else { | |
console.log('User has not enable Dark mode'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment