Componentsv2.189.1
Iconsv1.19.0
MCPv0.8.62
Tokensv0.34.3

The Toggle component renders a switch to toggle between enabled or disabled states.

Structure

The Toggle component is built using a native HTML <input type="checkbox"> element. The input is visually hidden but remains in the accessibility tree, while a custom-styled <div> provides the visual track and thumb. Its <label> element points to the input's id so clicking the label allows toggling the control.

Assistive text (description and error) renders in separate elements below the input. Their IDs are automatically linked to the input through the aria-describedby attribute so that assistive technology will properly announce them.

ARIA

table
ElementAttributeDescription
Inputaria-describedbyReferences the description and error text elements. When both are present, both IDs are included. Custom text may be set.
Inputaria-labelProvides an accessible name when no visible label is rendered.
Inputaria-labelledbyReferences the visible label element's ID. When a custom ariaLabelledby prop is also provided, both IDs are included so the input is named by all referenced elements.
Trackaria-hidden="true"Hides the decorative track and thumb from assistive technology.

Labels

We highly recommend adding visible labels with the label prop to prevent a lapse in communication. If a visible label is unneeded for the use case, add an ariaLabel or ariaLabelledby so assistive technology will announce the Toggle to the user. Omitting a label will result in an error.

Keyboard

table
KeyFunction
SpaceToggles the input between checked and unchecked.
Shift+TabMoves focus to the previous focusable element.
TabMoves focus to the next focusable element.

On this page