Skip to content

Switch

Switch

<Switch>Receive email updates</Switch>
<Switch defaultSelected>Dark mode</Switch>

Install: @helixui/core

import { Switch } from '@helixui/core'

status: stable · since: 0.1.0

Tags: toggle, on-off, setting

Live playground

Open the full editor or source on GitHub.

Anatomy

(○──) off
(──●) on (filled brand)

Layout

  • displayinline-flex
  • widthcontent
  • heightcontent
  • intrinsicSize~32×20 toggle + label
  • stackabletrue
  • fullBleedfalse

Visual

A pill-shaped track with a sliding circular knob. Off uses neutral track; on uses brand-filled track. Animates the knob with a soft transition.

Props

NameTypeDefaultDescription
isSelectedbooleanfalseControlled state.
defaultSelectedbooleanfalseUncontrolled initial state.
isDisabledbooleanfalseDisables interaction.
onChange(isSelected: boolean) => voidChange handler.
...restSwitchProps from react-aria-componentsAll forwarded.

Slots

  • children — visible label text

Tokens used

color.bg.action.neutral.active, color.bg.action.brand.default, color.text.primary, color.border.focus, color.white, radius.full, space.2, shadow.sm, font.family.sans, font.size.sm

Accessibility

Role: switch

Keyboard

KeyAction
SpaceToggles the switch.
EnterToggles the switch.

Notes

  • Use Switch for instant changes (mute audio, dark mode). Use Checkbox for opt-ins inside forms.

Composes with

ComponentRelationNote
FieldwrapsWrap if you need separate label/description structure.
CheckboxalternativeCheckbox for forms; Switch for instant settings.

Prompt examples

These are the AI prompt → JSX mappings used by the helixui prompt DSL and integrations like Cursor / Claude Code.

instant setting toggle

“switch for “Enable notifications""

<Switch isSelected={on} onChange={setOn}>Enable notifications</Switch>