Last active
March 19, 2022 13:01
-
-
Save AhmetEnesKCC/d05ab5974e019213b0db461bbee11b0e to your computer and use it in GitHub Desktop.
get system theme
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 getSystemTheme = () => { | |
// Check if the preferred scheme is dark | |
const isDarkMode = window.matchMedia("(prefers-color-scheme: dark)").matches; // Be careful! Not just parantheses and quotes, like ("()") this | |
const mode = isDarkmode ? "dark" : "light"; | |
return mode; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment