DEV Community

Discussion on: Light and dark mode in just 14 lines of CSS

Collapse
 
pcjmfranken profile image
Peter Franken

Here's a compatibility overview for the three major components to this implementation: caniuse.com/prefers-color-scheme,c...

The prefers-color-scheme is rather essential for pegging your css to the user's system theme, but the :root pseudo class and even the custom properties / variables could be left out - although that'd mean nesting all your css within those media queries 😉

Collapse
 
sinewalker profile image
Mike Lockhart

I use a static blog generator with a light theme that I have overridden by hand. Now with this idea I can just wrap my overrides in the media query.

Thread Thread
 
whitep4nth3r profile image
Salma Alam-Naylor

Sweet!