Skip to main content
Vuetify0 is now in alpha!
Vuetify0 Logo
Theme
Mode
Palettes
Accessibility
Vuetify One
Sign in to Vuetify One

Access premium tools across the Vuetify ecosystem — Bin, Play, Studio, and more.

Not a subscriber? See what's included

createGroup

Multi-selection with tri-state (mixed/indeterminate) support for checkbox trees, grouped toggles, and any pattern where items can be partially selected.


IntermediateApr 5, 2026

Usage

The createGroup composable manages a group of selectable items, letting you work with both their IDs and their position indexes. It supports selecting, unselecting, toggling, and reading the indexes of selected items.

ts
import { createGroup } from '@vuetify/v0'

// Instantiate group
const group = createGroup()

// Register items
group.register({ id: 'apple', value: 'Apple' })
group.register({ id: 'banana', value: 'Banana' })
group.register({ id: 'cherry', value: 'Cherry' })
group.register({ id: 'date', value: 'Date' })

// Select some items
group.select(['apple', 'banana'])
console.log(group.selectedIndexes.value) // Set { 0, 1 }

// Toggle an item (banana will become unselected)
group.toggle('banana')
console.log(group.selectedIndexes.value) // Set { 0 }

// Unselect apple
group.unselect('apple')
console.log(group.selectedIndexes.value) // Set {}

Context / DI

Use createGroupContext to share a group-selection instance across a component tree:

ts
import { createGroupContext } from '@vuetify/v0'

export const [useCheckboxGroup, provideCheckboxGroup, checkboxGroup] =
  createGroupContext({ namespace: 'my:checkboxes' })

// In parent component
provideCheckboxGroup()

// In child component
const group = useCheckboxGroup()
group.selectAll()

Architecture

createGroup extends createSelection with multi-select and tri-state capabilities:

Group Selection Hierarchy

Use controls to zoom and pan. Click outside or press Escape to close.

Group Selection Hierarchy

Reactivity

Group selection state is always reactive, including the tri-state mixedIds set.

Property/MethodReactiveNotes
selectedIdsshallowReactive(Set) — always reactive
mixedIdsshallowReactive(Set) — tracks indeterminate state
mixedItemsComputedRef<Set> — ticket instances in mixed state
selectedIndexesComputed from selectedIds
selectedItemsComputed from selectedIds
selectedValuesComputed from selectedItems
isAllSelectedtrue when all non-disabled items are selected
isNoneSelectedtrue when no items are selected
isMixedtrue when some but not all items are selected — use for header checkbox
selectAll()-Select all non-disabled items
unselectAll()-Unselect all items
toggleAll()-Toggle all non-disabled items
mix(ids)-Set one or more tickets to indeterminate state
unmix(ids)-Clear indeterminate state from one or more tickets
mixed(id)-Returns true if the ticket is in mixed state
ticket isSelectedComputed from selectedIds
ticket isMixedReadonly<Ref<boolean>> — whether this ticket is indeterminate
ticket mix()-Set this ticket to indeterminate state
ticket unmix()-Clear indeterminate state from this ticket

Examples

Chip Filter

Chip filters are a common pattern for narrowing content by tags. This example shows how createGroup handles per-item toggling, bulk selection via a tri-state header, and reactive state queries (isAllSelected, isMixed, isNoneSelected) — all out of the box.

Chip Tag Filter

Toggleable tag chips with a tri-state select-all header, showing isAllSelected, isMixed, and isNoneSelected update live.

FileRole
context.tsTag type, factory, and seed data
TagFilter.vueChip cloud with tri-state select-all header
chip-filter.vueEntry point — wires filter to a results list
0 / 6 selected

Showing all:

VueReactSvelteAngularSolidQwik

API Reference

The following API details are for the createGroup composable.

Functions

createGroup

(_options?: GroupOptions) => R

Creates a new group instance with batch selection and tri-state support. Extends `createSelection` to support selecting, unselecting, and toggling multiple items at once by passing an array of IDs. Adds tri-state (mixed/indeterminate) support for checkbox trees and similar use cases.

createGroupContext

(_options?: GroupContextOptions) => ContextTrinity<R>

Creates a new group context.

useGroup

(namespace?: string) => R

Returns the current group instance.

Options

events

boolean | undefined

Enable event emission for registry operations

Default: false

reactive

boolean | undefined

Enable reactive behavior for registry operations

Default: false

disabled

MaybeRefOrGetter<boolean> | undefined

Disabled state for the entire model instance

Default: false

enroll

MaybeRefOrGetter<boolean> | undefined

Auto-select tickets on registration

Default: true

multiple

MaybeRefOrGetter<boolean> | undefined

Allow multiple tickets to be selected simultaneously

Default: false

mandatory

MaybeRefOrGetter<boolean | "force"> | undefined

Controls mandatory selection behavior: - `false` (default): No mandatory selection enforcement - `true`: Prevents deselecting the last selected item - `'force'`: Automatically selects the first non-disabled item on registration

Properties

collection

ReadonlyMap<ID, E>

The collection of tickets in the registry

size

number

The number of tickets in the registry

selectedIds

Reactive<Set<ID>>

Set of currently selected ticket IDs

selectedItems

ComputedRef<Set<E>>

Computed Set of selected ticket instances

selectedValues

ComputedRef<Set<E["value"] extends Ref<infer U, infer U> ? U : E["value"]>>

Computed Set of selected ticket values

disabled

MaybeRefOrGetter<boolean>

Disabled state for the entire model instance

multiple

MaybeRefOrGetter<boolean>

Whether the selection allows multiple selections

selectedIndexes

ComputedRef<Set<number>>

mixedIds

Reactive<Set<ID>>

Set of mixed/indeterminate ticket IDs

mixedItems

ComputedRef<Set<E>>

Set of mixed/indeterminate ticket instances

isNoneSelected

ComputedRef<boolean>

Whether no items are currently selected

isAllSelected

ComputedRef<boolean>

Whether all selectable (non-disabled) items are selected

isMixed

ComputedRef<boolean>

Whether some but not all selectable items are selected

Methods

clear

() => void

Clear the entire registry

has

(id: ID) => boolean

Check if a ticket exists by ID

keys

() => readonly ID[]

Get all registered IDs

browse

(value: E["value"]) => ID[] | undefined

Browse for an ID(s) by value

lookup

(index: number) => ID | undefined

lookup a ticket by index number

get

(id: ID) => E | undefined

Get a ticket by ID

upsert

(id: ID, ticket?: Partial<Z>, event?: string) => E

Update or insert a ticket by ID

values

() => readonly E[]

Get all values of registered tickets

entries

() => readonly [ID, E][]

Get all entries of registered tickets

unregister

(id: ID) => void

Unregister a ticket by ID

reindex

() => void

Reset the index directory and update all tickets

move

(id: ID, toIndex: number) => E | undefined

Seek for a ticket based on direction and optional predicate

seek

(direction?: "first" | "last", from?: number, predicate?: (ticket) => boolean) => E | undefined

on

<K extends Extensible<RegistryEventName>>(event: K, cb: EventHandler<E, K>) => void

Listen for registry events

off

<K extends Extensible<RegistryEventName>>(event: K, cb: EventHandler<E, K>) => void

Stop listening for registry events

emit

<K extends Extensible<RegistryEventName>>(event: K, data: EventPayload<E, K>) => void

Emit an event with data

dispose

() => void

Clears the registry and removes all listeners

offboard

(ids: ID[]) => void

Offboard multiple tickets at once

batch

<R>(fn: () => R) => R

Execute operations in a batch, deferring cache invalidation and event emission until complete

reset

() => void

Reset selection state without destroying the registry

selected

(id: ID) => boolean

Check if a ticket is currently selected

apply

(values: unknown[], options?: { multiple?) => void

Apply external values to the model

mandate

() => void

Mandate selected ID based on "mandatory" option

select

(ids: ID | ID[]) => void

Select one or more Tickets by ID

unselect

(ids: ID | ID[]) => void

Unselect one or more Tickets by ID

toggle

(ids: ID | ID[]) => void

Toggle one or more Tickets ON and OFF by ID

mix

(ids: ID | ID[]) => void

Set one or more Tickets to mixed/indeterminate state by ID

unmix

(ids: ID | ID[]) => void

Clear mixed/indeterminate state from one or more Tickets by ID

mixed

(id: ID) => boolean

Check if a ticket is in mixed/indeterminate state by ID

selectAll

() => void

Select all selectable (non-disabled) items

unselectAll

() => void

Unselect all items (respects mandatory option)

toggleAll

() => void

Toggle between all selected and none selected

register

(ticket?: Partial<Z>) => E

Register a new ticket (accepts input type, returns output type)

onboard

(registrations: Partial<Z>[]) => E[]

Onboard multiple tickets at once

Was this page helpful?

© 2016-1970 Vuetify, LLC
Ctrl+/