A high-performance switch component with Indigo primary feedback and accessible aria-role implementation.
The sliding background track that transitions from gray to Indigo-600 when enabled.
The physical circular switch that slides 18px across the track with 200ms duration.
// ExperimentToggle.tsx
const ExperimentToggle = ({ enabled, onChange }) => (
<label className="relative inline-block w-10 h-6">
<input type="checkbox" className="sr-only" checked={enabled} onChange={onChange} />
<div className={`w-10 h-6 rounded-full transition-colors ${enabled ? 'bg-indigo-600' : 'bg-gray-200'}`} />
<div className={`absolute left-1 top-1 bg-white w-4 h-4 rounded-full transition-transform ${enabled ? 'translate-x-4' : ''}`} />
</label>
);