Toggle group
A row of buttons where one or several stay pressed.
<template> <NuiToggleGroup v-model="view" :items="views" variant="segmented" required label="Order list view" /></template><script setup lang="ts">import { ref } from 'vue';import { LayoutGrid } from '@lucide/vue';import { NuiToggleGroup, type NuiToggleItem } from '@numior/kit';const view = ref<string | null>('table');const views: readonly NuiToggleItem[] = [ { value: 'table', label: 'Table', icon: 'table' }, { value: 'cards', label: 'Cards', icon: LayoutGrid },];</script>Describe the buttons in items, and v-model gets the value of the pressed one.
Installation
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.
<template> <NuiToggleGroup label="Orders to show" v-model="scope" :items="scopes" /></template><script setup lang="ts">import { ref } from 'vue';import { NuiToggleGroup, type NuiToggleItem } from '@numior/kit';const scope = ref<string | null>('all');const scopes: NuiToggleItem[] = [ { value: 'all', label: 'All', icon: 'inbox' }, { value: 'new', label: 'New', icon: 'clock' }, { value: 'mine', label: 'Mine', icon: 'user' },];</script>Examples
Press several buttons
Add multiple.
Showing 10 of 12 orders
<template> <div class="flex flex-col gap-3"> <NuiToggleGroup v-model:values="deliveries" :items="methods" multiple label="Delivery method" /> <p class="m-0 text-sm text-muted-foreground">{{ summary }}</p> </div></template><script setup lang="ts">import { computed, ref } from 'vue';import { NuiToggleGroup } from '@numior/kit';import { DELIVERIES, orders } from './orders';const deliveries = ref(['courier', 'pickup']);const methods = Object.entries(DELIVERIES).map(([value, label]) => ({ value, label }));const shown = computed(() => orders.reduce((count, order) => count + Number(deliveries.value.includes(order.delivery)), 0),);const summary = computed(() => `Showing ${shown.value} of ${orders.length} orders`);</script>export type OrderStatus = 'pending' | 'paid' | 'shipped' | 'delivered' | 'cancelled';export type Payment = 'card' | 'transfer' | 'cash';export type Delivery = 'courier' | 'pickup' | 'post';export interface OrderLine { readonly sku: string; readonly name: string; readonly quantity: number; readonly price: number;}export interface Order { readonly id: number; readonly date: string; readonly customer: string; readonly city: string; readonly status: OrderStatus; readonly payment: Payment; readonly delivery: Delivery; readonly manager: string; readonly total: number; readonly lines: readonly OrderLine[];}export const ORDER_STATUSES: Record<OrderStatus, string> = { pending: 'Awaiting payment', paid: 'Paid', shipped: 'Shipped', delivered: 'Delivered', cancelled: 'Canceled',};export const PAYMENTS: Record<Payment, string> = { card: 'Card', transfer: 'Bank transfer', cash: 'On delivery',};export const DELIVERIES: Record<Delivery, string> = { courier: 'Courier', pickup: 'Pickup', post: 'Mail',};export const orders: readonly Order[] = [ { id: 20401, date: '2026-09-16', customer: 'Peter Wolfe', city: 'Boston', status: 'delivered', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 307, lines: [ { sku: 'S-101', name: 'Oslo armchair', quantity: 1, price: 249 }, { sku: 'X-507', name: 'Linen pillow', quantity: 2, price: 29 }, ], }, { id: 20402, date: '2026-09-17', customer: 'Lena Ortiz', city: 'Chicago', status: 'delivered', payment: 'card', delivery: 'pickup', manager: 'Anna Turner', total: 138, lines: [{ sku: 'L-401', name: 'Nord table lamp', quantity: 2, price: 69 }], }, { id: 20403, date: '2026-09-18', customer: 'Tim Sayed', city: 'Denver', status: 'delivered', payment: 'transfer', delivery: 'courier', manager: 'Maria Kim', total: 507, lines: [ { sku: 'T-201', name: 'Malmo desk', quantity: 1, price: 329 }, { sku: 'S-104', name: 'Bergen chair', quantity: 2, price: 89 }, ], }, { id: 20404, date: '2026-09-19', customer: 'Vera Lane', city: 'Boston', status: 'cancelled', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 180, lines: [{ sku: 'S-110', name: 'Loft stool', quantity: 4, price: 45 }], }, { id: 20405, date: '2026-09-20', customer: 'Glen Nash', city: 'Austin', status: 'delivered', payment: 'cash', delivery: 'post', manager: 'Maria Kim', total: 175, lines: [ { sku: 'X-501', name: 'Wool throw', quantity: 1, price: 59 }, { sku: 'X-507', name: 'Linen pillow', quantity: 4, price: 29 }, ], }, { id: 20406, date: '2026-09-21', customer: 'Evan Porter', city: 'Seattle', status: 'shipped', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 199, lines: [{ sku: 'H-301', name: 'Vik shelving unit', quantity: 1, price: 199 }], }, { id: 20407, date: '2026-09-22', customer: 'Mary Cooper', city: 'Portland', status: 'shipped', payment: 'transfer', delivery: 'post', manager: 'Maria Kim', total: 416, lines: [ { sku: 'L-408', name: 'Arc floor lamp', quantity: 1, price: 119 }, { sku: 'L-412', name: 'Sphere pendant', quantity: 3, price: 99 }, ], }, { id: 20408, date: '2026-09-23', customer: 'Paul Hawkins', city: 'Boston', status: 'shipped', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 368, lines: [ { sku: 'H-305', name: 'Fjord dresser', quantity: 1, price: 299 }, { sku: 'L-401', name: 'Nord table lamp', quantity: 1, price: 69 }, ], }, { id: 20409, date: '2026-09-24', customer: 'Olga Graham', city: 'Chicago', status: 'paid', payment: 'card', delivery: 'pickup', manager: 'Maria Kim', total: 139, lines: [{ sku: 'T-207', name: 'Tromso coffee table', quantity: 1, price: 139 }], }, { id: 20410, date: '2026-09-25', customer: 'Sam Ellis', city: 'Denver', status: 'paid', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 863, lines: [ { sku: 'S-104', name: 'Bergen chair', quantity: 6, price: 89 }, { sku: 'T-201', name: 'Malmo desk', quantity: 1, price: 329 }, ], }, { id: 20411, date: '2026-09-26', customer: 'Nina Hart', city: 'Austin', status: 'pending', payment: 'transfer', delivery: 'courier', manager: 'Maria Kim', total: 498, lines: [{ sku: 'S-101', name: 'Oslo armchair', quantity: 2, price: 249 }], }, { id: 20412, date: '2026-09-27', customer: 'Alina Yusuf', city: 'Portland', status: 'pending', payment: 'card', delivery: 'pickup', manager: 'Anna Turner', total: 187, lines: [ { sku: 'X-501', name: 'Wool throw', quantity: 2, price: 59 }, { sku: 'L-401', name: 'Nord table lamp', quantity: 1, price: 69 }, ], },];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
| Mode | Group | Buttons |
|---|---|---|
| One value | radiogroup | radio with aria-checked |
With multiple | group | Buttons 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 | |
|---|---|---|---|---|
items*required required | 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. |