Skip to content

Toggle Group

A set of related toggles sharing one selection - single or multiple - built on Reka UI's ToggleGroup primitive.

Usage

Joined into one segmented control, same visual technique as ButtonGroup. type="single" (the default) behaves like a segmented radio group - selecting one item deselects the rest:

vue-html
<SToggleGroup :items="['List', 'Grid', 'Kanban']" default-value="List" />

Multiple selection

type="multiple" lets any number of items stay pressed at once - modelValue/defaultValue become an array instead of a single value:

vue-html
<SToggleGroup type="multiple" :items="items" :default-value="['bold']" />

Icon only

The item slot replaces an item's default icon+label content entirely - pair it with a visually-hidden label so the item still has an accessible name:

vue-html
<SToggleGroup :items="items" default-value="list">
  <template #item="{ item }">
    <SIcon :name="item.icon" class="size-4.5" />
    <span class="sr-only">{{ item.label }}</span>
  </template>
</SToggleGroup>

Orientation

vue-html
<SToggleGroup orientation="vertical" :items="['List', 'Grid', 'Kanban']" />

Disabled

disabled on the group blocks every item; disabled on one item blocks only that item:

vue-html
<SToggleGroup :items="[
  { label: 'List', value: 'list' },
  { label: 'Grid', value: 'grid', disabled: true },
]" />

Custom :ui

To see exactly what you'd be overriding - the current default classes for every slot and variant - here's ToggleGroup's own theme file:

Theme source "toggle-group" not found

Props

PropTypeDefault
items(string | ToggleGroupItem)[]-
type'single' | 'multiple''single'
modelValuestring | string[]-
defaultValuestring | string[]-
disabledboolean-
orientation'horizontal' | 'vertical''horizontal'
color'primary' | 'neutral' | 'secondary' | 'success' | 'danger' | 'info' | 'warning''primary'
size'sm' | 'md' | 'lg''md'
uiPartial<Record<ToggleGroupSlot, string | object>>-

ToggleGroupItem is { label: string, value: string, icon?: string, disabled?: boolean }.

Emits

EventPayload
update:modelValuestring | string[]

Slots

SlotPropsDescription
item{ item, pressed }Replaces an item's default icon+label content
Edit this page