Captain UI

Switch

Tap it, or grab the thumb and drag. It follows your finger, stretches as you press, and a flick decides.

npx shadcn@latest add https://captain-ui.vercel.app/r/switch.json

Let agents run tests

Before every pull request

Ask before merging

You approve each merge to main

Pause at the spend cap

Stops every swarm at $50 this month

Usage

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

<Switch label="Ask before merging" onCheckedChange={setAsk} />

Props

PropTypeDefaultWhat it does
checkedbooleanControlled state.
defaultCheckedbooleanfalseInitial state when uncontrolled.
onCheckedChange(checked: boolean) => voidCalled on tap, drag release or keyboard.
labelReactNodeVisible label; clicking it toggles too.
size"sm" | "md""md"36×22 or 46×28. The hit area is always 44px.
disabledbooleanDims and ignores input.

Keyboard

Space
Toggle
Enter
Toggle

Accessibility

  • role=switch with aria-checked.
  • The label is wired with aria-labelledby.
  • Dragging is optional: tap and keyboard do the same thing.