Usage
Label
Pass text or an element to label
to display beside the switch. By default, the switch row will grow to accommodate the width of the parent container.
Help text
Pass text or an element to label
to display beside the switch. By default, the switch row will grow to accommodate the width of the parent container.
Dark mode
To display a switch on a dark background, set theme
to "dark"
.
API Reference
Switch
Inherits properties from HTMLButtonElement
.
Prop | Type | Default |
---|---|---|
asChild | boolean | false |
checked | boolean | |
className | string | |
defaultChecked | boolean | |
disabled | boolean | |
helpText | string | |
label | ReactNode | |
name | string | |
onCheckedChange | (checked: boolean) => void | |
required | boolean | |
theme | "light" "dark" | "light" |
value | string | "on" |