Switch
Toggle switch for turning settings on or off, with an optional label, a supporting description linked for screen readers, and a configurable label position.
import { Switch } from "@plexui/vue/components/Switch";On Phone, put switches in labelled rows with a trailing control. Use compact previews to compare controls, and the settings screen to see them in context.
Examples
Overview
Enabled
Disabled
Label and description
Controlled state
Grouped settings
API
| Prop | Type | Default | Description |
|---|---|---|---|
checked / v-model:checked | boolean | — | Controlled state |
default-checked | boolean | — | Initial state (uncontrolled) |
label | string | — | Accessible label rendered next to the switch |
label slot | VNode[] | — | Rich label content; takes precedence over the label prop |
description | string | — | Secondary text below the label, linked via aria-describedby |
description slot | VNode[] | — | Rich description content; takes precedence over the description prop |
label-position | "start" | "end" | "end" | Label on the left (start) or right (end) |
color | "primary" | "accent" | "primary" | Checked track color. Accent reads --switch-accent-color, with platform green as its fallback. Disabled checked controls retain a muted accent. |
disabled | boolean | false | Prevent interaction |
required | boolean | — | Required for form submission |
name | string | — | Form field name |
value | string | "on" | Value when submitted |
class | string | — | CSS classes applied to the wrapper node |
id | string | — | The id of the switch element (generated when omitted) |
@update:checked | (next: boolean) => void | — | Emitted with the next state when toggled |
@focus | (event: FocusEvent) => void | — | Emitted when the switch gains focus |
@blur | (event: FocusEvent) => void | — | Emitted when the switch loses focus |
Other attributes and listeners land on the switch <button>. Built on Reka UI Switch. Inside a <form>, a hidden native checkbox mirrors the state so the value is submitted with the form.
Styling
Set --switch-accent-color once in your application's theme stylesheet for every color="accent" switch. The shared application accent recipe connects this token to primary actions and other form controls. The default color="primary" is unchanged.
The Overview includes all four states:
| State | Track and thumb | Interaction |
|---|---|---|
| Enabled, off | Neutral track; thumb at the start | Can toggle |
| Enabled, on | Accent track; thumb at the end | Can toggle |
| Disabled, off | Neutral disabled track; thumb at the start without a shadow | Cannot toggle |
| Disabled, on | Muted accent track; thumb at the end without a shadow | Cannot toggle |
On a phone the switch takes the measures of a native iOS 27.2 switch: a 63 × 28px track with a 37 × 24px thumb 2px in from its end, and an off track in the tertiary label color. The thumb casts no shadow, as the native one, a disabled switch keeps its enabled colors at half opacity, and while it is held the thumb turns into a clear lens of glass over the track.
Switch reads these component tokens. Override them at any scope to restyle it:
--field-label-font-weight: label font weight (defaultvar(--font-weight-medium))--switch-label-gap: label gap (defaultspacing(2))--switch-thumb-color: thumb color (defaultlight-dark(var(--gray-0), var(--gray-1000)))--switch-thumb-color-disabled: thumb color disabled (defaultlight-dark(var(--gray-0), var(--gray-800)))--switch-thumb-offset: thumb offset (default3px)--switch-thumb-shadow: thumb shadow (default0 1px 2px rgb(0 0 0 / 20%); on a phonenone)--switch-thumb-size: thumb size--switch-accent-color: checked track color whencolor="accent"(defaultlight-dark(#34c759, #30d158))--switch-track-color: track color (defaultlight-dark(var(--gray-150), var(--gray-400)); on a phone withtouch.cssthe tertiary label--mobile-label-tertiary, falling back to--alpha-25: the native off track)--switch-track-color-checked: track color checked (defaultlight-dark(var(--gray-900), var(--blue-400)))--switch-track-color-checked-disabled: track color checked disabled (defaultlight-dark(var(--gray-300), var(--blue-700)); a phone dims the enabled colors instead)--switch-track-color-disabled: track color disabled (defaultlight-dark(var(--gray-100), var(--gray-300)); a phone dims the enabled colors instead)--switch-track-color-hover: track color hover (defaultlight-dark(var(--gray-200), var(--gray-450)); on a phone--alpha-30)--switch-track-height: track height (default19px)--switch-track-width: track width (default32px)