Switch
On/off toggle with role="switch"; onChange receives the new boolean. Add showState to print | or 0 inside the track.
Props
checkedbooleanOn/off state.
onChange(checked: boolean) => voidCalled with the new state.
labelReactNodeLabel text.
showStatebooleanDefault:falsePrint | (on) or 0 (off) inside the track.
disabledbooleanDefault:falseDisable the control.
classNamestringDefault:''Extra classes for the root element.
...restAny other props are passed to the underlying element.
| Prop | Type | Default | Description |
|---|---|---|---|
checked | boolean | – | On/off state. |
onChange | (checked: boolean) => void | – | Called with the new state. |
label | ReactNode | – | Label text. |
showState | boolean | false | Print | (on) or 0 (off) inside the track. |
disabled | boolean | false | Disable the control. |
className | string | '' | Extra classes for the root element. |
...rest | – | Any other props are passed to the underlying element. |