Toggle
A switch with some weight to it. The knob stretches along its direction of travel and settles on a spring, so the flip feels thrown rather than snapped. Controlled or uncontrolled, three sizes, with an optional label and hint.
Installation
npx stepwise-ui add toggle
Default
Sizes
With label
The label and hint are wired to the switch, so clicking either flips it.
Props
PropTypeDescription
checkedbooleanControlled state.
defaultCheckedbooleanUncontrolled initial state.
onChange(checked: boolean) => voidFires on flip.
size"sm" | "default" | "lg"Default "default".
labelstringLabel beside the switch.
hintstringHelper line under the label.
ariaLabelstringAccessible name for the switch. Needed when used without `label`.
disabledbooleanDisables the switch.
classNamestringMerged onto the outer wrapper.