import { useId } from 'react' interface ToggleProps { label: string description?: string checked: boolean onChange: (v: boolean) => void disabled?: boolean } /** * Brand-colored switch. Implemented as a real `` * (visually hidden) wrapped in a `` so screen readers, keyboard * navigation, and form autofill behave correctly. The visible "track" * is decorative and tied to the input via `aria-hidden`. */ export default function Toggle({ label, description, checked, onChange, disabled }: ToggleProps) { const inputId = useId() const descId = description ? `${inputId}-desc` : undefined return ( onChange(e.target.checked)} // Visually hidden but still focusable + reachable by AT. className="peer absolute inset-0 h-full w-full cursor-inherit opacity-0 disabled:cursor-not-allowed" /> {label} {description && ( {description} )} ) }