Forms
Switch
An on/off control for settings that take effect immediately. The thumb glides; while pressed, it stretches slightly, as if held.
Installation #
With the Nuxt module, every component is auto-imported — there is nothing to add. In a plain Vue project, import what you use:
Copy
import { JSwitch } from '@juxtui/ui'Usage #
Copy
<JSwitch v-model="enabled" label="Email notifications" />Use a switch when the change applies immediately. When it only applies after submitting a form, use a checkbox.
Variants & examples #
Settings list#
Build every pull request.
Collect anonymous usage metrics.
Try features before they ship.
Sizes and states#
API #
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| modelValue | boolean | false | Bound with v-model. |
| label | string | — | Label text. |
| description | string | — | Supporting text. |
| size | 'sm' | 'md' | 'md' | Track size. |
| disabled | boolean | false | Disables the switch. |
| name | string | — | When set, submits value under this name while on. |
| value | string | 'on' | Submitted value. |
Events
| Event | Payload | Description |
|---|---|---|
| update:modelValue | boolean | Emitted when toggled. |
Slots
| Slot | Props | Description |
|---|---|---|
| default | — | Custom label content. |
| description | — | Custom description content. |
Accessibility #
- A
<button role="switch">witharia-checked, labelled by its visible label. - Clicking the label toggles the switch.
Keyboard #
| Key | Action |
|---|---|
| Space | Toggles the switch. |
| Enter | Toggles the switch. |