UIComponentsReact
A set of tags that can be selected as filters or removed, each a chip.
Built on the headless Tag Group.See its API in Docs
Rendered by React 19.3.1
Installation
npx shadcn@4.23.0 add https://hamur.dev/r/react/tag-group.jsonIt also adds utils, button. The app needs its setup first: Installation.
Usage
Put one TagGroupTag per tag inside TagGroup, each holding a TagGroupTagContent with a TagGroupTagText. To let tags be removed, handle onRemove and add a TagGroupTagRemove to each content; to let them be selected, set selectable (and multiple for several). A TagGroupEmpty shows while the group has no tags. Name the group with aria-label or aria-labelledby. The selection, the removal keys, the focus and the announcements come from the headless Tag Group.
import {
TagGroup,
TagGroupEmpty,
TagGroupTag,
TagGroupTagContent,
TagGroupTagRemove,
TagGroupTagText,
} from '@/components/ui/tag-group'Examples
Default
Labels with their remove buttons, and the empty text once all are gone.
Selectable
Filters selected several at a time, the selected ones with a check.
Rendered by React 19.3.1
A tag is a filled chip. A selected tag is outlined in primary and shows a check before its text, and a disabled tag is dashed and unfilled, so neither state is told by its color only (WCAG 1.4.1). The remove button is the Button's ghost icon-xs, 24 by 24 CSS pixels (WCAG 2.5.8). A focused tag rings its chip. This item takes Base UI's component ID as its slug and one name per Base UI part.
API reference
The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Tag Group's API reference.