Switch
Binary toggle control. The thumb slides along a spring curve, with a slight stretch on press for physical质感.
Basic Usage
vue
<ASwitch v-model="value" />Size
vue
<ASwitch v-model="value" size="sm" />
<ASwitch v-model="value" size="md" />Loading / Disabled
vue
<ASwitch v-model="value" loading />
<ASwitch v-model="value" disabled />API
Props
| Name | Type | Default | Description |
|---|---|---|---|
modelValue | boolean | false | Toggle state |
size | 'sm' | 'md' | 'md' | Size |
disabled | boolean | false | Disabled |
loading | boolean | false | Loading state, shows spinner |
Emits
| Name | Parameters | Description |
|---|---|---|
update:modelValue | boolean | State toggled |
Accessibility
- Uses native
<button role="switch">,aria-checkedreflects state - Space / Enter keys to toggle
- Focus ring follows global
:focus-visiblestyle