Installation
npx shadcn@latest add @iconiq/switchProps
Switch
7 props
Binary on or off control built on Radix Switch, with a motion-driven thumb travel, foreground fill sweep, and optional inline label.
checked
booleanControlled checked state. Pass this when the parent owns the current on or off value.
defaultChecked
booleanInitial checked state for uncontrolled usage. The component keeps its local animation state in sync with this mode too.
onCheckedChange
(checked: boolean) => voidCalled whenever the switch changes state, after the thumb and fill animation sequence starts.
disabled
booleanDisables pointer and keyboard interaction, and dims the switch and optional label together.
label
stringOptional inline text rendered beside the switch. When omitted, the component returns only the switch control itself.
labelSide
"left" | "right"Default
rightControls which side of the switch the optional label text appears on.
className
stringMerged onto the Radix root element for local spacing or surface overrides.
Notes
Additional Radix switch props such as aria-label, name, value, required, and form are forwarded to the root control.
If you provide label, the component wraps the control in a native label element so clicking the text also toggles the switch.