Switch
Switch
Section titled “Switch”Category: Forms & inputs
<Switch>Receive email updates</Switch><Switch defaultSelected>Dark mode</Switch>Install: @helix-ui/core
import { Switch } from '@helix-ui/core';status: stable · since: 0.1.0
Tags: toggle, on-off, setting
Live playground
Section titled “Live playground”Open the full editor or source on GitHub.
Anatomy
Section titled “Anatomy”(○──) off(──●) on (filled brand)Layout
Section titled “Layout”- display —
inline-flex - width —
content - height —
content - intrinsicSize —
~32×20 toggle + label - stackable —
true - fullBleed —
false
Visual
Section titled “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.
| Name | Type | Default | Description |
|---|---|---|---|
isSelected |
boolean |
false |
Controlled state. |
defaultSelected |
boolean |
false |
Uncontrolled initial state. |
isDisabled |
boolean |
false |
Disables interaction. |
onChange |
(isSelected: boolean) => void |
— | Change handler. |
...rest |
SwitchProps from react-aria-components |
— | All forwarded. |
- children — visible label text
Tokens used
Section titled “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
Section titled “Accessibility”Role: switch
Keyboard
| Key | Action |
|---|---|
Space |
Toggles the switch. |
Enter |
Toggles the switch. |
Notes
- Use Switch for instant changes (mute audio, dark mode). Use Checkbox for opt-ins inside forms.
Composes with
Section titled “Composes with”| Component | Relation | Note |
|---|---|---|
Field |
wraps |
Wrap if you need separate label/description structure. |
Checkbox |
alternative |
Checkbox for forms; Switch for instant settings. |
Prompt examples
Section titled “Prompt examples”These are the AI prompt → JSX mappings used by the helix-ui prompt DSL and integrations like Cursor / Claude Code.
instant setting toggle
Section titled “instant setting toggle”“switch for “Enable notifications”“
<Switch isSelected={on} onChange={setOn}> Enable notifications</Switch>