Skip to content

Toggle

Props

PropTypeDefaultOptionsDescription
modelValuebooleanfalseOn (true) or off (false).
disabledbooleanfalseDisables interaction and applies disabled styles (including on-state muted track)
sizestring"m"m, lTrack and thumb dimensions
namestring""name on the host for form submission
valuestring"on"Value submitted when the toggle is on
ariaLabelstring""Accessible name when the default slot has no visible label
testSelectorsobjectSee Test SelectorsOverride data-test attributes

See Component API — Props.

Slots

NameDescription
(default)Optional label beside the switch. When present, the control uses aria-labelledby (unless aria-label is set, which takes precedence).

See Component API — Slots.

Events

NameDetailDescription
update:modelValuebooleanEmitted when the user changes the state

From the DOM, this is a CustomEvent. The payload is in event.detail, and with Vue’s custom-element runtime it is usually a one-element array — read event.detail[0] (same normalization as v-catnip-model in packages/components/src/core/directives.ts). In Vue templates, listen with @update:modelValue="fn"; the handler often receives the native event, so use fn(ev) and unwrap ev.detail as above.

See Component API — Events.

Test Selectors

AttributeDefault Value
rootcatnip-toggle
switchcatnip-toggle-switch

See Component API — Test selectors.

Forms

When native form behaviour is enabled, the submitted value is the value attribute while model-value is true, and the field is omitted (or empty) when off. Boolean model-value is handled explicitly for catnip-toggle so ElementInternals.setFormValue receives a string (or null), not a raw boolean.

Catnip Design System by Signicat