Skip to content

Instantly share code, notes, and snippets.

@miladganjali
Created November 17, 2021 23:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save miladganjali/0d7614d53c5b20b4edc352f71a1e116f to your computer and use it in GitHub Desktop.
Simple Dark mode detector
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