easy10 min

Build a Toggle

Build a toggle switch component that alternates between ON and OFF states. The toggle should visually indicate its current state and change when clicked. Practice boolean state management and conditional rendering.

useStateconditional rendering
  • Renders with initial state OFF
  • Toggles to ON when clicked
  • Toggles back to OFF when clicked again
  • Button label reflects the current state
Your Code
Loading editor...