Forms / Switch

Forms

Switch

An on/off setting that takes effect at once: a native checkbox with role=switch, so Space toggles it and it posts with a form.

import { EcoSwitch } from "vue-ecosphere"

States

Use a switch when flipping it applies the change; use a checkbox when the choice waits for Save. The label names what is on; no On/Off word beside it.

With a hint

Sizes

The small switch fits dense rows and table cells.

Saving

Set loading while the change saves: the switch shows the new state, marks itself busy and ignores input until the save settles.

EcoSwitch

NameTypeDefaultDescription
v-modelbooleanfalseOn state.
labelstring—The thing that is true while it is on, beside the track. Default slot overrides.
hintstring—Second line (switch__h), wired with aria-describedby. #hint slot.
disabledbooleanfalseSay why in the hint.
loadingbooleanfalseA save in flight: aria-busy, an indicator in the thumb, and input is ignored.
size"md" | "sm""md"sm for dense rows and table cells.
namestring—Native name; the form posts on (or the value attribute) while it is on.
idstring—Input id; generated when omitted.
…attrs——aria-label (for a switch with no visible label), value and listeners go to the <input>; class/style to the label.