DEV Community

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

Collapse
 
inspiredlabs profile image
Inspired Labs - London, United Kingdom

Dark mode in 10 lines of code: codepen.io/inspiredlabs/pen/OJQpPg...

Collapse
 
whitep4nth3r profile image
Salma Alam-Naylor

Interesting approach! Except I'm viewing it in dark mode which shows white text on a grey background — which I can't read 😅

Collapse
 
inspiredlabs profile image
Inspired Labs - London, United Kingdom

Exactly! Using var(--color-bg, inherit) uses the browser's fallback value. Perhaps one day, browsers will simply have a algo to do this themselves, such as Luma: css-tricks.com/switch-font-color-f...