Skip to content
GaudiGaudi Design System home

Search documentation

Search every page, heading and paragraph.

useSelection

Multi-select state in a Set, with select-all and indeterminate support.

HooksData@gaudi/design-system/hooks/data/use-selectionView in StorybookSource

Tracks selected ids for lists, tables and bulk actions. Uncontrolled from initialSelectedIds, or controlled with selectedIds and onSelectionChange; every change produces a new Set.

Usage

import { useSelection } from '@gaudi/design-system/hooks';
const { isSelected, toggleSelection, getSelectAllState, toggleAll, count } = useSelection();

Examples

Bulk actions with select all

Storybook

Controlled with a limit

Storybook

API

3 options
5 return values

Accessibility

Give every checkbox a label naming its row, give the select-all checkbox an indeterminate state, and announce bulk results (for example with useLiveAnnouncer).

Notes

  • DataTable has its own selection; use this hook for custom lists, galleries and cards.