Created
November 17, 2021 23:03
-
-
Save miladganjali/0d7614d53c5b20b4edc352f71a1e116f to your computer and use it in GitHub Desktop.
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