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.
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.
ariaLabelstringInvisible accessible name, for when a visible element outside this component already labels it and `label` would render that text a second time. ⚠ `label` on this component is **visible**; `IconButton.label`/`Sparkline.label` are invisible names, which is the prior that costs adopters a duplicated label. The raw DOM `aria-label` still wins over this.

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