Skip to content

Switch โ€‹

A boolean toggle with sizes, color variants, optional loading state, and slot-overridable label and description text. Toggle Vue / CSS to switch the live demo and source together.

Basic โ€‹

Single switch with a label.

Vue SFC

Sizes โ€‹

Small, medium and large.

Vue SFC

Colors โ€‹

All built-in color variants.

Vue SFC

States โ€‹

Disabled, loading and pre-checked.

Vue SFC

Description โ€‹

Switch with a secondary description line.

Vue SFC

Slots โ€‹

Custom label and description via named slots.

Vue SFC

Event: change โ€‹

Listen to mno-change to react to toggling.

Vue SFC

Event log โ€‹

Live log of mno-change events.

Vue SFC

Customized โ€‹

Compose a card-style switch with your own CSS โ€” the library ships no helper. The .switch-card class is applied to the root via cssClass (Vue) / directly (CSS).

Vue SFC

CSS Variables โ€‹

Vue SFC

Every switch is themed through --mono-switch-* custom properties. Setting one on the element, on any wrapper/ancestor, or inline all work โ€” custom properties inherit, and they pierce the shadow-DOM boundary, so the same overrides apply to <mono-switch> and the shadow build. The color prop sets the accent, but an explicit --mono-switch-accent override always wins. To re-skin globally, set the underlying --theme-* tokens โ€” they feed the defaults below.

VariableDefaultControls
--mono-switch-accent--theme-primaryTrack color when on (set by color)
--mono-switch-track-offtheme border mixTrack color when off
--mono-switch-track-off-hoverprimary mixOff-track color on hover
--mono-switch-thumb#ffffffThumb color
--mono-switch-thumb-shadow0 1px 3px โ€ฆThumb shadow
--mono-switch-shadow0 1px 2px โ€ฆTrack shadow
--mono-switch-ringprimary 22%Focus-visible ring color
--mono-switch-text--theme-textLabel text color
--mono-switch-description#6b7280Description text color
--mono-switch-gap0.75remGap between control and label

Types โ€‹

Importimport { SwitchProps } from 'mono-helper'
PropValueDefaultDescription
modelValuebooleanโ€”Two-way bound on/off state of the switch.
checkedbooleanโ€”Whether the switch is checked (kept in sync with modelValue).
color'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info'โ€”Color theme of the switch.
size'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'โ€”Size of the switch.
disabledbooleanโ€”Disables interaction with the switch.
loadingbooleanโ€”Shows a loading state and blocks interaction.
labelstringโ€”Text label shown next to the switch.
descriptionstringโ€”Secondary description text shown under the label.
valuestringโ€”Value submitted with the form when checked.
namestringโ€”Form field name for the underlying input.
ariaLabelTextstringโ€”Accessible label for screen readers.
ariaLabelstringโ€”โ€”
cssClassSwitchCssClassโ€”Per-part class overrides for styling internal elements.
visiblebooleanโ€”Whether the control is shown. Defaults to `true`.
visibleType'invisible' | 'none'โ€”How it hides when `visible` is `false`. Defaults to `'none'`.