Created
May 23, 2022 09:52
-
-
Save nirnejak/8db4c6b600f1744990f3e8b41a08a449 to your computer and use it in GitHub Desktop.
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
const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)') | |
handleDarkmode(darkModeMediaQuery) | |
function handleDarkmode(e) { | |
const darkModeOn = e.matches; // true if dark mode is enabled | |
if (darkModeOn) { | |
// TODO: Set Dark Theme | |
} else { | |
// TODO: Set Light Theme | |
} | |
} | |
darkModeMediaQuery.addListener(handleDarkmode); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment