Switch
Use VSwitch for an on/off setting applied immediately. It exposes role="switch" to assistive technology.
Usage
vue
Examples
Hint
Use label or the default slot for the name. hint adds help text linked through aria-describedby.
vue
Joins known networks automatically.
Visible to nearby devices while on.
Label position
labelPosition="start" places the label before the switch.
vue
Full width
spread fills the available width and places the label and switch at opposite ends.
vue
Read-only
readonly prevents changes by click or Space while preserving focus and native form behavior. It sets aria-readonly.
vue
Disabled
disabled prevents changes and removes the switch from Tab navigation and form submission.
vue
API
Props
| Prop | Type | Default |
|---|---|---|
label | string | none |
Visible label, replaced by the default slot. Without either, provide aria-label or aria-labelledby. | ||
hint | string | none |
Help text below the label, linked through aria-describedby. | ||
error | string | none |
Error message shown in place of the hint. Sets aria-invalid, is linked through aria-describedby and is announced when it appears. | ||
labelPosition | SwitchLabelPosition'start' | 'end' | 'end' |
Label before the switch with start, or after it with end. | ||
spread | boolean | false |
| Fills the available width and separates the label and switch. | ||
invalid | boolean | false |
Sets aria-invalid and the error style. Does not block form submission by itself. | ||
disabled | boolean | false |
| Disables the switch and excludes it from focus and form submission. | ||
readonly | boolean | false |
Prevents changes while keeping the switch focusable. Sets aria-readonly; native form submission and validation still apply. | ||
v-model | boolean | false |
On/off state, a boolean defaulting to false. Use native name and value attributes for form submission. | ||
Slots
| Slot | Type |
|---|---|
default | {} |
Clickable label content, replacing label. | |
CSS variables
| Token | Value |
|---|---|
--vectis-control-size-switch-w | 2.25rem |
--vectis-control-size-switch-h | 1.25rem |
--vectis-control-size-switch-pad | 0.125rem |