Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted almost 3 years ago

Dashboard with automatic day/night color scheme switching

P
J Cooper•290
@jefcooper
A solution to the Social media dashboard with theme switcher challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


For this challenge I tried to make my javascript more reusable and spent time covering all the edge cases. I've used the @media prefers-color-scheme queries along with CSS so that I have three theme classes, theme--light, theme--dark, and theme--default. theme--default uses the @media queries to automatically follow the system preferred scheme, while light/dark themes are used to pin user preference via javascript when needed.

I've tried to make this one accessible, but it was awkward. One problem I had was attaching the arrow svg's via ::before pseudo classes. The screen reader insists on announcing the image, no matter what. In the end I used a .visually-hidden span and aria-none in a couple of places to clean up the screen reader experience.

Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

No feedback yet. Be the first to give feedback on J Cooper's solution.

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner
  • Use cases

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License