Switch
A toggle that powers on like a neon tube.
Turns off cellular, Wi-Fi and Bluetooth.
Connected to Studio 5G
Pauses downloads and background refresh until you charge.
Installation
npx shadcn@latest add https://neonkit.heyaadi.com/r/switch.jsonUsage
import { Switch } from "@/components/ui/switch"
<Switch label="Airplane mode" />Examples
Sizes
Colors
Pass a palette name or any hex value to color.
Controlled
Pair checked with onCheckedChange to drive other UI from the state.
API reference
Renders a button with role="switch" and accepts its attributes; the ref points at the button. With a label, className and style go to the wrapper around both.
| Prop | Type | Default |
|---|---|---|
checked | booleanControlled on state. | None |
defaultChecked | booleanInitial state when uncontrolled. | false |
onCheckedChange | (checked: boolean) => voidCalled with the new state on every toggle. | None |
label | ReactNodeClickable label after the switch, linked with aria-labelledby. | None |
name | stringRenders a hidden input so the switch submits with a form when on. | None |
value | stringValue submitted under name. | "on" |
color | NeonColorPalette name or hex. Falls back to --neon-accent, then cyan. | inherited |
size | "sm"Track of 28, 36 or 44px wide. | "md" |
disabled | booleanBlocks interaction and dims the switch. | false |
Accessibility
- The track has an invisible target at least 44px tall, so the small switch is still easy to tap.
- With name, a form reset puts the switch back to where it started.
- Space and Enter toggle the switch, and aria-checked reports its state.
- Without a label, pass an aria-label or point a label element at the switch id.
- The power-on flicker is skipped when the user prefers reduced motion, and never plays for switches that are already on when they mount.