Skip to content
Theme:

Ui3nSwitch ​

Switch component for toggling boolean values.

Props

NameTypeDefaultDescription
idstring | undefined —

Root element id

namestring | undefined —

HTML name attribute for form submission

modelValue*boolean —

Current switch value

sizestring | number | undefined16

Switch size

colorstring | undefined"var(--color-icon-control-accent-default)"

Switch color

disabledboolean | undefinedfalse

Whether switch is disabled

Events

Event NameArguments / Value TypeDescription
update:modelValuevalue: boolean —
changevalue: boolean —

Slots

Slot NameScope Props (v-slot)Description
#default —

Default slot

Public Methods & Exposes

Method NameSignature / TypeDescription
clear()() => void —

CSS Variables

Set any of these where you need it — on :root, on a container, or on the element itself through [data-ui3n] — and the component follows. Leave them alone and it uses the defaults below.

NameDefault
--ui3n-switch-colorvar(--color-icon-control-accent-default)
--ui3n-switch-dot-margincalc(var(--_switch-size) / 8)
--ui3n-switch-dot-sizecalc(var(--_switch-size) / 4 * 3)
--ui3n-switch-font-colorvar(--color-text-control-primary-default)
--ui3n-switch-font-size12px
--ui3n-switch-font-weight500
--ui3n-switch-off-colorvar(--color-bg-table-cell-pressed)
--ui3n-switch-size16px

Usage Examples ​

Simple switch ​

Simple switch

Basic switch toggle

Switch with label ​

Switch with label

Switch with label using default slot

Customized switch ​

Customized switch

Switch with custom size and color