Can someone help me with making a JS code that return with document.write “Light” when users have light mode on and “Dark” when they have dark mode on (on their iOS device)
Asked
Active
Viewed 261 times
0
-
1In CSS there is a dark mode media query https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme – evolutionxbox Jan 26 '20 at 23:36
1 Answers
0
This has already been asked here:
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
// dark mode
}

TKret96
- 426
- 4
- 14
-
For future reference, if a question is a duplicate you should use the "Flag" function on the question to indicate this, rather than adding an answer. – Paulw11 Jan 27 '20 at 00:45