For AI agents: the complete documentation index is available at https://wallarm.github.io/design-system/llms.txt, the full documentation bundle is available at https://wallarm.github.io/design-system/llms-full.txt, and this page is available as Markdown at https://wallarm.github.io/design-system/components/switch.md.

Switch

Turns one setting on or off, and takes effect the moment it is flipped — reach for Checkbox when the answer is submitted with a form, and ToggleButton when the control belongs in a toolbar rather than a settings list. Because there is no Save to undo it, avoid a switch for anything destructive or slow.

Source · Storybook

Usage

import { Switch, SwitchControl, SwitchLabel } from '@wallarm-org/design-system/Switch';

Examples

Checked

The on state. The track fills with brand and the thumb travels, so on and off differ by both colour and position.

Disabled

Dimmed and not clickable, in both states. A disabled switch still shows where the setting stands, which is the point of showing it at all.

With description

SwitchDescription adds a second line and switches the row to a grid, so the text aligns with the label rather than the track.

Multiple

Several switches in a column. They are independent settings, not a choice between options — if only one may be on, that is a Radio group.

Accessibility mode

a11yMode draws a tick or a cross inside the track, so the state survives being read without colour. Worth turning on wherever the setting matters more than the aesthetic.

Props

PropTypeDefaultDescription
a11yModeboolean | undefinedfalse
titlestring | undefined
defaultCheckedboolean | undefined
defaultValuestring | number | readonly string[] | undefined
autoFocusboolean | undefined
idstring | undefined
tabIndexnumber | undefined
relstring | undefined
onChangeChangeEventHandler<T, Element> | undefined
htmlForstring | undefined
labelstring | undefinedSpecifies the localized strings that identifies the accessibility elements and their states
disabledboolean | undefinedWhether the switch is disabled.
namestring | undefinedThe name of the input field in a switch (Useful for form submission).
valuestring | number | undefinedThe value of switch input. Useful for form submission.
idsElementIds | undefinedThe ids of the elements in the switch. Useful for composition.
readOnlyboolean | undefinedWhether the switch is read-only
requiredboolean | undefinedIf true, the switch input is marked as required,
onCheckedChange((details: CheckedChangeDetails) => void) | undefinedFunction to call when the switch is clicked.
invalidboolean | undefinedIf true, the switch is marked as invalid.
checkedboolean | undefinedThe controlled checked state of the switch
asChildboolean | undefinedUse the provided child element as the default rendered element, combining their props and behavior.
data-testidstring | undefined

SwitchDescription

PropTypeDefaultDescription
titlestring | undefined
defaultCheckedboolean | undefined
defaultValuestring | number | readonly string[] | undefined
autoFocusboolean | undefined
idstring | undefined
tabIndexnumber | undefined
relstring | undefined
onChangeChangeEventHandler<T, Element> | undefined

SwitchLabel

PropTypeDefaultDescription
titlestring | undefined
defaultCheckedboolean | undefined
defaultValuestring | number | readonly string[] | undefined
autoFocusboolean | undefined
idstring | undefined
tabIndexnumber | undefined
relstring | undefined
onChangeChangeEventHandler<T, Element> | undefined
asChildboolean | undefinedUse the provided child element as the default rendered element, combining their props and behavior.

Explorer