Social Media Dashboard with prefers-color-scheme and JS toggle
Dušan's questions for the community
In this project for the initial load, I've used
prefers-color-sheme that would trigger and respond to the theme of your computer. Every time when you change the theme on the computer website should also change color.
The approach above does not work as soon as the toggle was pressed at least once, because the toggle loads new CSS version of the light or a dark theme respectively. The issue that I've come across with this approach is that the link tag will be loaded every time, I was not sure how to fix that so if you have any suggestion just let me know :)
Give some feedback to DEmanderbag about their solution
Join our Slack community
Join over 40,000 people taking the challenges, talking about their code, helping each other, and chatting about all things front-end!