Color
Typography
Spacing
Radius
Border
Opacity
Elevation
Blur
Avatar
Badge
Button
Checkbox
Input
ProgressBar
RadioButton
Separator
Slider
Switch
TextArea
TextLink
Accordion
Breadcrumb
ButtonGroup
Combobox
DropdownMenu
ListItem
Pagination
SegmentedControl
Select
Tooltip
Calendar
Card
CommandMenu
DatePicker
Dialog
Drawer
EmptyState
Footer
Form
NavigationBar
Sidebar
Skeleton
Table
Tabs
Toaster

Switch

On/off control that applies immediately. Two values (Off, On), two sizes and five states. Includes a label and optional supporting text.

Caption text

Toggled
Size

Usage

Import the component and render it.

import { Switch } from 'src/components/Switch/Switch';

<Switch size="md" label="Switch label" caption="Caption text" />

Accessibility

Role: switch (Radix Switch: <button role="switch"> with aria-checked).

KeyAction
SpaceToggles between on and off
EnterToggles between on and off
TabMoves focus (shows the Focus state via :focus-visible)
  • Use a Switch for settings that apply immediately; use a Checkbox when the choice is submitted with a form.
  • The label is a <label for> the switch: clicking it toggles the value.
  • The caption is linked with aria-describedby and is not part of the accessible name.
  • Hover/Pressed states also apply when pointing at the label, not only the track.

Size

Set the size prop: Small is "sm", Medium is "md".

Caption text

Small

Caption text

Medium
<Switch size="sm" label="Switch label" />
<Switch size="md" label="Switch label" />

Toggled

Set the checked prop: Off is {false}, On is {true}.

Caption text

Off

Caption text

On
<Switch label="Switch label" />
<Switch checked label="Switch label" />

States

Disabled comes from the disabled prop. Hover, Focus and Pressed follow the pointer and the keyboard: try them in the playground.

Caption text

Default

Caption text

Disabled
<Switch disabled label="Switch label" />

Used in

Switch is part of ListItem.

Actions

Pass callbacks to respond to the component.

import { Switch } from 'src/components/Switch/Switch';

<Switch
  size="md"
  label="Switch label"
  caption="Caption text"
  onCheckedChange={(checked) => console.log(checked)}
/>
CallbackWhen
onCheckedChangeFires when the value changes.