loading...

re: Add dark mode to your website with just a few lines of code VIEW POST

TOP OF THREAD FULL DISCUSSION
re: According to CanIUse.com [prefers-color-scheme] support is at around 78%, leaving out Internet Explorer and Edge (not Edge Chromium). Correct me ...
 

You can always fallback to light theme in case this feature is not supported.

 

Of course. Better yet, do use a toggle, and don't rely on something unreliable :)

Using both is the preferred option. Support in OS/Browsers for prefers-color-scheme will only increase. Which means if you implement now, you will support more users in the future, rather than doing it later.

Secondly, in initial hit of your site, you can set their preferred theme according to their preferred color schema (dark mode on first hit). If you only rely on a toggle, you force users to use the light mode regardless of their preferred setting.

Correct, combining both is the best idea.

Admittedly, I should have worded this better, as that is what I do. Check for a LocalStorage preference that I set when the user toggles dark mode, and check the schema if the key isn't set.

code of conduct - report abuse