Forms
Toggle Group
A row of buttons acting as one control, for choosing one or several mutually visible options.
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 { JToggleGroup, JToggleGroupItem } from '@juxtui/ui'Usage #
Copy
<JToggleGroup v-model="align" label="Text alignment">
<JToggleGroupItem value="left">Left</JToggleGroupItem>
<JToggleGroupItem value="center">Center</JToggleGroupItem>
<JToggleGroupItem value="right">Right</JToggleGroupItem>
</JToggleGroup>In single mode (the default) the model is one value or null; in multiple mode it’s an array. Nothing else about the markup changes.
Unlike JTabs, no content is tied to the selection — use a toggle group for settings and formatting choices, not for switching between panels.
Variants & examples #
Multiple selection#
Set type="multiple" and bind an array.
Sizes#
Disabled#
API #
JToggleGroup
| Prop | Type | Default | Description |
|---|---|---|---|
| modelValue | string | string[] | null | null | Bound with v-model. A single value (or null) in single mode, an array in multiple mode. |
| type | 'single' | 'multiple' | 'single' | single keeps at most one item pressed; multiple lets any number stay pressed. |
| size | 'sm' | 'md' | 'md' | Height of the items. |
| disabled | boolean | false | Disables every item in the group. |
| label | string | — | Accessible name for the group. |
Events
| Event | Payload | Description |
|---|---|---|
| update:modelValue | string | string[] | Emitted when an item is toggled. |
Slots
| Slot | Props | Description |
|---|---|---|
| default | — | The JToggleGroupItem items. |
JToggleGroupItem
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | — | Identifies this item in the group’s v-model. Required. |
| disabled | boolean | false | Disables this item, on top of the group’s own disabled. |
| label | string | — | Accessible name, for when the slot content isn’t descriptive enough (e.g. an icon-only item). |
Slots
| Slot | Props | Description |
|---|---|---|
| default | — | Item content — text, an icon, or both. |
Accessibility #
- Follows the WAI-ARIA toolbar pattern: the group is
role="group"witharia-label, and arrow keys move real focus between native<button>items so pointer and keyboard state never disagree. - Each item is a native
<button>witharia-pressed, reflecting its selected state — announced as a toggle button, not a radio or checkbox, in bothsingleandmultiplemode. - Give icon-only items a
label, sincearia-pressedalone doesn’t explain what the button does.
Keyboard #
| Key | Action |
|---|---|
| →↓ | Move focus to the next item, wrapping around. Disabled items are skipped. |
| ←↑ | Move focus to the previous item, wrapping around. Disabled items are skipped. |
| HomeEnd | Move focus to the first or last item. |
| SpaceEnter | Toggle the focused item. |