Switch

A binary on/off toggle for settings. It's a role="switch" button (keyboard and screen-reader friendly) that fills with the accent token when on. Use it for instant-apply preferences; for form submits prefer a checkbox.

States

Off, on, and disabled in both positions.

Controlled

Drive it from state with checked + onCheckedChange. Omit checked and pass defaultChecked to let the switch manage its own state.

Props

PropTypeDefaultDescription
checkedbooleanControlled state. Omit for uncontrolled.
defaultCheckedbooleanfalseInitial state when uncontrolled.
onCheckedChange(checked: boolean) => voidFired with the next state on toggle.
disabledbooleanfalseDisables interaction.
classNamestringExtra classes on the track.
thumbClassNamestringExtra classes on the moving thumb.

Any other native <button> attributes (aria-*, id, …) are forwarded.