Created
April 27, 2024 18:03
-
-
Save juji/a5fa2590abe52a2899987dc960959d21 to your computer and use it in GitHub Desktop.
Detect dark mode
This file contains hidden or 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
((w,d) => { | |
w && d && | |
w.matchMedia('(prefers-color-scheme:dark)')?.matches && | |
d.getElementsByTagName('html')[0]?.classList.add('dark') | |
})(window,document) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment