Skip to content

Toggle group ​

A row of buttons where one or several stay pressed.

Describe the buttons in items, and v-model gets the value of the pressed one.

Installation ​

ts
import { NuiToggleGroup } from '@numior/kit';

Usage ​

Change the style and the size of the group, stack the buttons in a column or leave only their icons.

variant
Style: outline for separate outlined buttons, segmented for buttons in one bar.
size
Size of the buttons: sm, md or lg.
orientation
Lays out the buttons in a row or a column. A column uses the up and down arrows.

Label of the group for screen readers.

Examples ​

Press several buttons ​

Add multiple.

Showing 10 of 12 orders

The pressed values come to v-model:values as an array, and the user can release every button: required works only for a single value.

Behavior ​

When the buttons do not fit, the group scrolls with a swipe, the mouse wheel and the arrow buttons. An arrow shows up only at the edge that hides buttons, and the pressed button is fully in view on load.

While the group can still scroll in the direction of the wheel, the page does not scroll. A vertical group does not scroll.

Accessibility ​

ModeGroupButtons
One valueradiogroupradio with aria-checked
With multiplegroupButtons with aria-pressed

Name the group in label. Tab stops on the pressed button, and the arrow keys move between the others; in right-to-left text the left and right arrows swap.

Keys
Action
→
Moves to the next button. In a column, use ArrowDown.
←
Moves to the previous button. In a column, use ArrowUp.
Home
Moves to the first button.
End
Moves to the last button.
Space
Presses or releases the button.

API ​

Props

Name
Type
Default
Description
itemsrequired
readonly NuiToggleItem<T>[]
—
Buttons of the group with value and label, plus optional icon and disabled.
multiple
boolean
false
Lets several buttons be pressed. The values come in v-model:values.
required
boolean
false
Keeps the last pressed button from being released so the value never empties. Works with multiple too.
variant
NuiToggleGroupVariant
"outline"
Style: outline for separate outlined buttons, segmented for buttons in one bar.
size
NuiSize
"md"
Size of the buttons: sm, md or lg.
orientation
NuiToggleGroupOrientation
"horizontal"
Lays out the buttons in a row or a column. A column uses the up and down arrows.
disabled
boolean
false
Turns off every button of the group, so none can be pressed or reached with Tab.
iconOnly
boolean
false
Shows icons only. The label appears in a tooltip on hover and is read by screen readers.
label
string
—
Label of the group for screen readers.
getKey
NuiOptionKey<T>
—
Function that returns a key for an object value. Without it, the JSON of the value is used.

Models

Name
Type
Default
Description
v-model
T | null
null
Value of the pressed button without multiple, or null.
v-model:values
T[]
[]
Values of the pressed buttons with multiple.

Slots

Name
Slot props
Description
item
NuiToggleItemSlot<T>
Custom button content. Receives item and selected.

Edit this page

Search

Esc