Toggle

The Toggle component is used to switch between two states, such as on/off.

Usage & Examples

Default

default.tsx

const [checked, setChecked] = useState(false);

<Toggle
  checked={checked}
  onChange={setChecked}
  label="Enable setting"
  theme="primary"
/>

Props API

21 props
Columns
Toggle props API
Default
Description
aria-describedbystringNoariaReferences the id of an element that describes the toggle, such as hint text or supporting content.
aria-disabledbooleanNoariaExplicitly communicates disabled state to assistive technologies. Normally inferred from `disabled`, but exposed for flexibility.
aria-errormessagestringNoariaReferences the id of an element containing an error message.
aria-invalidbooleanNoariaIndicates whether the current value is invalid.
aria-labelstringNoariaAccessible label for screen readers. Best used when no visible label is rendered.
aria-labelledbystringNoariaReferences the id of an element that labels the toggle. Takes precedence over aria-label when provided.
checkedbooleanYespropsIndicates whether the toggle is in the "on" (`true`) or "off" (`false`) state.
classNamestringNostylingAdditional CSS class names for custom styling.
data-testidstringNotestingBackward-compatible alias for test ID attributes.
disabledbooleanNopropsfalseIf true, disables user interaction with the toggle.
glassbooleanNopropsconfigured default glass setting (fallback: false)Applies a translucent frosted-glass treatment to the toggle track.
idstringNopropsOptional id for the toggle button. If not provided, one will be generated automatically.