AhaSlides Design
v0.52.0React · Vue · Lit

Components · Data Entry

Switch

A single setting that takes effect immediately — on or off.

Examples

Size
State
Interactivity
Children
Switch · on · off · disabled · loading · small · with checked/unchecked children
In a settings row · applies immediately

API

PropTypeDefaultNotes
checkedbooleanfalseOn/off state (reflected)
disabledbooleanfalseNon-interactive
loadingbooleanfalseSpinner in the knob; blocks toggle while busy (aria-busy)
size'default' | 'small'defaultTrack 44×22 (default) or 28×16 (small)
on-textstringText shown inside the track when on
off-textstringText shown inside the track when off
on-iconicon nameDS icon shown inside the track when on (wins over on-text)
off-iconicon nameDS icon shown inside the track when off (wins over off-text)
changeCustomEvent<{checked}>Composed event on toggle; read e.detail.checked

Install

# .npmrc — once: point the @ahaslides-product scope at GitHub Packages
@ahaslides-product:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}   # a GitHub token with read:packages

npm i @ahaslides-product/design
import '@ahaslides-product/design/tokens.css';   // once, at the app root
import '@ahaslides-product/design/aha-switch';   // registers <aha-switch>

Agent feed for this component (absolute, fetchable anywhere): switch.agent.json · switch.md · switch.llms.txt

When to use

When to use
  • Switch — a single setting that applies immediately — no save step
  • Checkbox — options saved together as a group, or expressing consent
  • Radio — exactly one from a small mutually-exclusive set
Never mix switches and checkboxes in one group. The label names what the setting controls as a noun phrase; the switch communicates the action — don't prefix the label with Enable/Turn on. Reach for `loading` on an async setting that may fail, `size=small` in a dense list, and checked/unchecked children only when the on/off meaning isn't obvious from context.
Surfaces
editor dashboard settings audience

Spec

Track 44×22 (small 28×16) · radius pill · 1px #D4D4D4 border · Knob 18×18 white circle, slides 20px (small 12×12, slides 12px) · Off track #F7F7F7 (gray-20) · On track #6A1EBB (primary) · Disabled 40% opacity, not-allowed · Loading system-circle-notch spinner rides in the knob; interaction blocked · Children optional text or icon inside the track, away from the knob (checked ↔ unchecked)