Toggle

On/off switch built as an accessible button

Category: inputs · WCAG 2.2-AA · switch, form, boolean

Sizes

States

Props

PropTypeDefaultDescription
checkedbooleanWhether the control is checked (controlled).
defaultCheckedbooleanfalseWhether the control is checked on first render (uncontrolled).
onValueChange(checked: boolean) => voidCalled with the new checked state when the switch is toggled.
onChange(checked: boolean) => voidDeprecated: use onValueChange (same checked boolean).
labelstringVisible text label beside the switch; it also becomes the accessible name. When a heading already labels the control, omit this and pass aria-label instead to avoid duplicated text.
size'sm' | 'md'mdVisual size of the component (e.g. 'sm', 'md', 'lg').
disabledbooleanfalseWhen true, disables the control and removes it from the tab order.

Design tokens

When to use

When not to use

How to build an accessible Toggle in React →

Examples

Uncontrolled

<Toggle label="Notifications" defaultChecked />

Controlled

<Toggle checked={enabled} onValueChange={setEnabled} label="Dark mode" />

Related components

← Back to docs