✦ Asteria UI
Components

Switch

Toggle switch for on/off binary settings, built on Radix UI.

Installation

npx asteria-ui add switch

Usage

import { Switch } from "@/components/ui/switch";

<Switch label="Email notifications" />

Examples

States

API reference

PropTypeDefaultDescription
labelReactNodeClickable label, linked to the control via for/id.
checkedbooleanControlled checked state.
defaultCheckedbooleanUncontrolled initial checked state.
onCheckedChange(checked: boolean) => voidCalled when the switch is toggled.
disabledbooleanPrevents toggling.

Accessibility

Accessibility

  • Role. role="switch" with aria-checked true/false — provided by Radix.

  • Keyboard. Space toggles.

  • Label. Clicking the label toggles the switch.

  • Focus. Visible glow-focus ring on the track.