createGroup
Multi-selection with tri-state (mixed/indeterminate) support for checkbox trees, grouped toggles, and any pattern where items can be partially selected.
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.
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:
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:
Reactivity
Group selection state is always reactive, including the tri-state mixedIds set.
| Property/Method | Reactive | Notes |
|---|---|---|
selectedIds | shallowReactive(Set) — always reactive | |
mixedIds | shallowReactive(Set) — tracks indeterminate state | |
mixedItems | ComputedRef<Set> — ticket instances in mixed state | |
selectedIndexes | Computed from selectedIds | |
selectedItems | Computed from selectedIds | |
selectedValues | Computed from selectedItems | |
isAllSelected | true when all non-disabled items are selected | |
isNoneSelected | true when no items are selected | |
isMixed | true 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 isSelected | Computed from selectedIds | |
ticket isMixed | Readonly<Ref<boolean>> — whether this ticket is indeterminate | |
ticket mix() | - | Set this ticket to indeterminate state |
ticket unmix() | - | Clear indeterminate state from this ticket |
Examples
Showing all:
FAQ
Both are multi-select, but createGroup adds tri-state support — mixedIds, isMixed, and mix()/unmix() — plus batch helpers like selectAll() and toggleAll(). Reach for it when you need a select-all header checkbox or indeterminate states; plain createSelection has neither.
Read isAllSelected, isMixed, and isNoneSelected to choose the checkbox state, and wire the header to toggleAll(). isMixed is true when some but not all items are selected.
Selected means the item is in selectedIds; mixed (indeterminate) means it’s only partially selected — typically a parent whose children are some-selected. Read it with mixed(id) or ticket isMixed, set it with mix()/unmix(). For automatic parent/child cascading, see createNested.
No. selectAll(), unselectAll(), and toggleAll() act only on non-disabled items, and isAllSelected is true once every non-disabled item is selected — a disabled row is skipped, so it never keeps the select-all header from reading as fully checked.