Skip to Content
ComponentsSwitch

Switch

Toggle component with a thumb element. Accessible — renders as a <button role="switch"> with aria-checked.

Preview

Anatomy

import { Switch } from '@wire-ui/react' <Switch.Root checked={on} onCheckedChange={setOn}> <Switch.Thumb /> </Switch.Root>

Root props

PropTypeDefaultDescription
checkedbooleanControlled checked state
defaultCheckedbooleanfalseInitial state for uncontrolled use
onCheckedChange(checked: boolean) => voidCalled when toggled
disabledbooleanfalseDisables the switch

Data attributes

AttributeElementValues
data-stateRoot, Thumb"checked" / "unchecked"
data-disabledRootPresent when disabled

Accessibility

  • role="switch" with aria-checked reflects the current state
  • Keyboard: Space toggles the switch
Last updated on

MIT License © 2026 wire-ui