switch

Switch

Turns one setting on or off the moment it is pressed, such as order emails; sits beside its label in a Field and mirrors in a right-to-left page.

States: Default, Focus, Checked, Disabled, Invalid

Parts

PartFileDoes
SwitchSwitch.vueLets the user turn a single setting on or off.

Styling

PartRecipe
Switchswitch
Switchswitch-thumb

Install

Writes 2 files into components/ui/switch/. For agents, npx @frontic/ui docs switch prints this reference as markdown; the MCP server serves the same.

Installs with it
use-field-control
npm packages
@vueuse/core
class-variance-authority
reka-ui

API reference

Switch Switch.vue

Lets the user turn a single setting on or off. Renders a <button>.

PropTypeDefault
defaultValueboolean—
modelValueboolean | null—
disabledbooleanfalse
idstring—
valuestring'on'
trueValueboolean—
falseValueboolean—
asChildbooleanfalse
asAsTag | Component'button'
namestring—
requiredbooleanfalse
classClassValue—
size'md' | 'sm''md'
EventPayload
update:modelValuepayload: boolean
SlotSlot props
thumb{ modelValue: boolean; checked: boolean; }
Data attributeValues
data-disabled—
data-size'md' | 'sm'
data-state'checked' | 'unchecked'
Recipe switchSets
base: switch 9 properties
size: mddefault 2 properties
size: sm 2 properties
focus-ringshared state 3 properties
invalidshared state 3 properties
disabledshared state 1 property
Recipe switch-thumbSets
base: switch-thumb 5 properties
size: mddefault 1 property
size: sm 1 property
Example
State