Skip to content

Switch ​

Switch toggles between two states. Supports custom activate event, styles, and disabled state.

Basic usage ​

Bind state with v-model; use activeClass and unactiveClass for active/inactive styles.

Disabled ​

Use the disabled prop and disabledClass for disabled styling.

Activate event ​

Use activateEvent to choose the event that toggles the switch: click, mouseenter, mousedown, mouseup, dblclick, contextmenu, touchstart, touchend.

Switch Props ​

NameTypeDefaultDescription
modelValuebooleanfalseCurrent state; use with v-model
classClassType-Root element class
activeClassClassType-Class when on
unactiveClassClassType-Class when off
activateEvent'click' | 'mouseenter' | 'mousedown' | 'mouseup' | 'dblclick' | 'contextmenu' | 'touchstart' | 'touchend''click'Event that toggles
disabledbooleanfalseWhether disabled
disabledClassClassType-Class when disabled
asstring'div'Root HTML tag

Switch Events ​

NamePayloadDescription
update:modelValue(value: boolean)Emitted when state changes (v-model)
change(value: boolean)Emitted when state changes
reject(value: any)Emitted when user tries to toggle while disabled

Switch Slots ​

NamePayloadDescription
default{ active: boolean, isDisabled: boolean }Custom content; receives current active and disabled state