It's super easy to include a dark theme for your existing websites using CSS. In this tutorial, we're going to do this by taking advantage of CSS V...
For further actions, you may consider blocking this person and/or reporting abuse
Simple and clean. Well done!!
Thanks 😊
We can also approach it with SASS
Nice one! 👏
Thanks mate!
Very beautifull!
But if I choose the light theme and close the site, the next time I open the site in light mode but the selector is on "auto".
That's strange, does it work for other modes?
I explain better perhaps you don't understand:
1 I choose the light mode
2 I close the site with the light mode on
3 I reopen the site
3 the select shows me the voice auto instead of light
I just copied the code directly out of the article and it appears to work fine. Do you have any errors coming up? Or a typo perhaps?
I've also made the code available here:
codepen.io/dcode-software/pen/ZEQMEjG
No i havent any error
EDIT now is correct i had a problem with w3 Total Cache
I think loading jQuery is overkill to only keep a single value in a cookie or local storage.
I prefer to stay as close to W3C standards as possible : most of the time a commented code snippet can do the job as well, and greatly reduce potential security flaws versus any library.
Nice but this method is not supported by IE
But no one will be using IE anymore since Edge Chromium has all of IE's legacy features baked in.
For IE you could simply have a "theme-dark.css" and "theme-light.css" (and also "theme-print.css" for... Printing) then use server or JavaScript code to include the suitable CSS file on the fly.
❤️💯
Good solution!
Thanks!
Great one I loved itt 😇😇🥰
You're welcome 😊
What if I wanted to do it with icons (or buttons) instead of with a select?
There is an error:
--text-color: var(dark-text-color);
should be
--text-color: var(--dark-text-color);