Switch
A control that allows the user to toggle between checked and not checked.
Features
- Full keyboard navigation.
- Can be controlled or uncontrolled.
Install the component from your command line.
Import the components and piece the parts together.
Create your styled switch component from the primitive parts.
Contains all the parts of a switch.
Prop | Type | Default | Required |
---|---|---|---|
as | enum | button | |
defaultChecked | boolean | ||
checked | boolean | ||
onCheckedChange | function | ||
disabled | boolean | ||
required | boolean | ||
readOnly | boolean | ||
name | string | ||
value | string | on |
The thumb that is used to visually indicate whether the switch is on or off.
Prop | Type | Default | Required |
---|---|---|---|
as | enum | span |
Adheres to the switch
role requirements.
Key | Description |
---|---|
Space | Toggles the component's state. |
Enter | Toggles the component's state. |