Tag Group
Installation
Add the component with the CLI.
npx shadcn@latest add @intentui/tag-group
Manual installation
Install the dependencies, then copy the component source into your project.
npm install react-aria-components @heroicons/react cn
Anatomy
import { Tag, TagGroup, TagList } from "@/components/ui/tag-group"
import { Label } from "@/components/ui/field"<TagGroup selectionMode="multiple">
<Label>Serverless</Label>
<TagList>
<Tag>AWS Lambda</Tag>
<Tag>Google Cloud Functions</Tag>
<Tag>Azure Functions</Tag>
</TagList>
</TagGroup>Examples
With remove button
Tags within the group can include a removal button.
Controlled
Manage the values of the tag group through the value prop.
Links
Incorporate a hyperlink within the tag group using the href prop.
For client-side routing, React Aria recommends using the onAction event to handle navigation programmatically instead of passing an href prop.
This is because some collection items cannot be rendered as native elements due to HTML specification limitations.
Disabled
Disable tags either by setting the isDisabled prop or using disabledKeys on the TagGroup.
Component API
Tag
Tag extends the React Aria Components <Tag> component.
classNamestringTagGroup
TagGroup extends the React Aria Components <TagGroup> component.
classNamestringTagList
TagList extends the React Aria Components <TagList> component.
classNamestringSee the React Aria for the full API reference.
