Frontendx
README.md
SOLUTION.md
main.tsxentry
App.tsx
App.css
index.html
vite.config.ts
Installed
react@^19.2.0
react-dom@^19.2.0

Toggle Switch in React

Prompt

Build a reusable animated toggle switch component (like iOS-style on/off switch). Accepts checked and onChange props for controlled usage. Smooth sliding animation when toggled. Should be accessible: keyboard focusable and supports Enter/Space to toggle.

Use a hidden checkbox input for accessibility or manage isOn state with onClick on a styled div. Apply CSS transform: translateX() on the thumb to slide it. Add transition for smooth animation. Emit onChange with new boolean value.
Test Results

Toggle Switch in React

Build a reusable animated toggle switch component (like iOS-style on/off switch). Accepts checked and onChange props for controlled usage. Smooth sliding animation when toggled. Should be accessible: keyboard focusable and supports Enter/Space to toggle.