Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 2 years ago

QR code component with theme toggler (dark/light), flexbox and BEM

bem
Muhammadjavohir•280
@Muhammadjewel
A solution to the QR code component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


My 6th challenge is completed 🎉

This visibly simple component was interesting to code. I've added some optional features, like dark theme toggler. Also, the page will save the theme value using localStorage and show the page with preferred theme even after page reload.

The page also will adapt to device's preferred-color-scheme. That was done using simple media query. I would recommend adding this in your future projects. Your websites users will probably happy for this feature.

UPDATE: Due to some reasons, if your phone is in dark mode, the theme toggler was not working. I removed this features until I find the workaround. Your help in this issue is highly welcome.

UPDATE 2: I fixed the issue. Now the page can adapt to user's default theme on page load. But, I could also improve the solution so the page would adapt to device's theme change instantly. Right now the user should refresh the page for changes to occur.

This video was very helpful for theme switching. The code is clean, too. https://youtu.be/Xk12JtYG8rw?si=cJT0kI_gwDJJ1B-7

Any constructive feedback is welcome.

In case you want to watch my live coding of the component, the video is here

Take care and good luck in your other FrontendMentor challenges 👍

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 Muhammadjavohir'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