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.

Parts

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

Styling

All of Switch’s styles live in switch.json. New to styling in Frontic UI? How styling works →

Install

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

API reference

Switch.vue

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

Props 13

PropTypeDefault
defaultValueboolean—
modelValueboolean | null—
disabledbooleanfalse
idstring—
valuestring'on'
trueValueboolean—
falseValueboolean—
asChildbooleanfalse
asAsTag | Component'button'
namestring—
requiredbooleanfalse
classClassValue—
size'md' | 'sm''md'

Events 1

EventPayload
update:modelValuepayload: boolean

Slots 1

SlotSlot props
thumb{ modelValue: boolean; checked: boolean; }

Data attributes 3

Data attributeValues
data-disabled—
data-size'md' | 'sm'
data-state'checked' | 'unchecked'

Recipe switch 6 groups

Recipe switch-thumb 3 groups

Switch
State