Switch

A switch with controlled and uncontrolled modes, role="switch" semantics and Space / Enter toggling.

Props

PropTypeDefaultDescription
checkedboolean—Controlled value; omit it to run uncontrolled
defaultCheckedbooleanfalseInitial value when uncontrolled
onCheckedChange(checked: boolean) => void—Called on every change, controlled or not
size'sm' | 'md''md'Control size: sm / md
disabledbooleanfalseWhether the switch is disabled
...restButtonHTMLAttributes—Remaining props are forwarded to the native button