Project

Animated round toggle

I spent a Friday evening building a round toggle component in React, just to prove myself it could be done.

Background

As part of a random task on my daily job, I created an icon that I thought would look cool as a toggle. I decided to build a round toggle component in React to see if I could replicate the design in code and make it interactive.

While I was there, I thought I'd make it infinitely scalable so I could display it on my portfolio without having to worry about the size.

Click the little buddies!

Development

I used React to build the component and CSS for the styling. I used `useState` to keep track of the toggle state and added a transition to the icon to make it move and rotate when toggled.

I struggled a bit with the animation parameters, because it's hard to make it look like a real rotation when the animation is too fast, but also it's easy to get bored when it is too slow. I think I found a good balance in the end.

You can check the code for this component in my GitHub repository.

‹ Back to projects