DEV Community

Discussion on: Add dark mode to your website with just a few lines of code

Collapse
supunkavinda profile image
Supun Kavinda

So, why would you prefer this to CSS variables?

Collapse
albertomontalesi profile image
AlbertoM Author

Can you elaborate more?

Collapse
coly010 profile image
Colum Ferry

CSS Variables for one aren't supported in IE11 : caniuse.com/#feat=css-variables

So for enterprise development you need a ponyfill to support this.

Otherwise, you could certainly set up your theme.css to have a set of CSS Variables you reuse in the rest of your CSS files, then dynamically change between light-theme or dark-theme or other custom themes with JS