Switch

An on/off toggle for settings that take effect immediately.
Stable
Web
iOS
Android
@advui/core
Source
JSX
<Switch aria-label="Airplane mode" />
size

Installation

pnpm
pnpm add @advui/core
npm
npm install @advui/core

Usage

import { HStack, Label, Switch } from '@advui/core'

<HStack gap="3">
  <Switch id="notifications" checked={enabled} onCheckedChange={setEnabled} />
  <Label htmlFor="notifications">Notifications</Label>
</HStack>

Examples

Settings list

Order updates and mentions.
Product news, at most once a month.

API reference

Switch

PropTypeDefaultDescription
checkedboolean—On or off, when you control it.
defaultCheckedboolean—Starting `checked` when uncontrolled.
onCheckedChange(checked: boolean) => void—Called when toggled.
size'sm' | 'md''md'36×20 or 44×24.
disabledbooleanfalsePrevents toggling.

Accessibility

  • Exposes role="switch" with aria-checked, and its checked and disabled states on iOS and Android too.
  • Use a Switch for immediate effects; use a Checkbox inside forms that need a submit.
  • The thumb animation is removed when reduced motion is requested.
Keyboard interactions
KeyAction
Space / EnterToggles the switch.

Platform notes

Web
Rendered as a <button role="switch"> with a hidden checkbox for forms.
iOS
Custom drawn for visual consistency across platforms.
Android
Custom drawn; TalkBack announces “switch, on/off”.
Since v0.1.0Last updated Nov 2, 2026Edit this page on GitHub