Examples
Basic
| Prop | Default | Type | Description |
|---|---|---|---|
modelValue | - | boolean | The controlled state of the switch. Can be bind as v-model. |
defaultValue | - | boolean | The uncontrolled state of the switch. |
value | on | string | The value of the switch. |
disabled | false | boolean | When true, prevents the user from interacting with the switch. |
Read more in Reka Switch Root API
Form Group
You can use the switch component inside the form-group component, or you can use it with the label component.
Notice that when you click on the label, the switch gets toggled.
Read more in Form-group component
Read more in Label component
Color
| Prop | Default | Type | Description |
|---|---|---|---|
switch-checked | primary | string | Change the color of the switch when checked. |
switch-unchecked | gray | string | Change the color of the switch when unchecked. |
Size
Adjust the switch size without limits. Use breakpoints (e.g., sm:sm, xs:lg) for responsive sizes or states (e.g., hover:lg, focus:3xl) for state-based sizes.
| Prop | Default | Type | Description |
|---|---|---|---|
size | md | string | Change the size of the switch. |
Icon
Configure the switch icon using the following props.
| Prop | Default | Type | Description |
|---|---|---|---|
icon | - | string | Add an icon that appears regardless of state. |
checkedIcon | - | string | Add an icon that appears when the switch is on. |
uncheckedIcon | - | string | Add an icon that appears when the switch is off. |
Loading
Set the switch to loading state.
| Prop | Default | Type | Description |
|---|---|---|---|
loading | - | boolean | Set the switch to loading. |
Customization
Configure the progress using the una prop and utility classes.
Read more in Component Props API
Read more in Component Presets
Slots
| Name | Props | Description |
|---|---|---|
icon | checked | Customizable icons for the switch in both checked and unchecked states. |
loading-icon | checked | The loading icon slot. |
Presets
shortcuts/switch.ts
Props
types/switch.ts