Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 1 year ago

A Calculator app with a 3-way theme toggle

react, tailwind-css
Semaj Primm•100
@semajthomasprimm
A solution to the Calculator app challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


What are you most proud of, and what would you do differently next time?

This project was fun and challenged me to develop an app with reusable code in mind.

A few things I learned and used in this project:

  • Using CSS attribute selectors to set the color of the toggle switch. I have 3 input components that represent each theme, with values from 0 to 2, inclusive. By accessing an input using input[value=""], I was able to color that input according to the selected theme.
  • Defining reusable colors using CSS variables. This allowed me to use the colors without writing repetitive hex-codes. I also made sure the names where identical across all themes so that I could define multiple themes regardless of hex value.
  • Setting up multiple themes using the @layer directive. In my tailwind config file, I was able to use the CSS variables to define the background and text colours.

Tools used:

  • React
  • TailwindCSS
  • CSS Grid & Flexbox

My development process

  • Developed the desktop frontend
  • Added functionality with useState.
  • Added responsive design for mobile and tablet screen sizes
  • Refactored components into separate files
  • Refactored arbitrary CSS classes into custom TailwindCSS styles
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 Semaj Primm'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