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.
| Variable | Default | Controls |
|---|---|---|
--mono-switch-accent | --theme-primary | Track color when on (set by color) |
--mono-switch-track-off | theme border mix | Track color when off |
--mono-switch-track-off-hover | primary mix | Off-track color on hover |
--mono-switch-thumb | #ffffff | Thumb color |
--mono-switch-thumb-shadow | 0 1px 3px โฆ | Thumb shadow |
--mono-switch-shadow | 0 1px 2px โฆ | Track shadow |
--mono-switch-ring | primary 22% | Focus-visible ring color |
--mono-switch-text | --theme-text | Label text color |
--mono-switch-description | #6b7280 | Description text color |
--mono-switch-gap | 0.75rem | Gap between control and label |
Types โ
Import
import { SwitchProps } from 'mono-helper'| Prop | Value | Default | Description |
|---|---|---|---|
modelValue | boolean | โ | Two-way bound on/off state of the switch. |
checked | boolean | โ | 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. |
disabled | boolean | โ | Disables interaction with the switch. |
loading | boolean | โ | Shows a loading state and blocks interaction. |
label | string | โ | Text label shown next to the switch. |
description | string | โ | Secondary description text shown under the label. |
value | string | โ | Value submitted with the form when checked. |
name | string | โ | Form field name for the underlying input. |
ariaLabelText | string | โ | Accessible label for screen readers. |
ariaLabel | string | โ | โ |
cssClass | SwitchCssClass | โ | Per-part class overrides for styling internal elements. |
visible | boolean | โ | Whether the control is shown. Defaults to `true`. |
visibleType | 'invisible' | 'none' | โ | How it hides when `visible` is `false`. Defaults to `'none'`. |