TagGroup

A set of selectable or removable tags.

  • Composed
  • New in 0.1
import { TagGroup, tagGroupPrimitive } from "nitro-ui-sdk/tag-group";
HeroUI Native
TagGroup
Expo UI
No counterpart
  • TagGroup example screen, light appearance
    Light
  • TagGroup example screen, dark appearance
    Dark
On this page

Coordinates a wrapping set of selectable or removable tags built on Chip. Use TagGroup for topic filters, multi-select categories, or removable token lists; use Chip for a single standalone tag or RadioGroup for mutually exclusive radio rows.

Anatomy

<TagGroup.Root label="Topics" selectionMode="multiple" defaultValue={["ios"]} onRemove={(key) => {}}>
  <TagGroup.Label />
  <TagGroup.List>
    <TagGroup.Tag value="ios" label="iOS" icon="apple.logo" />
    <TagGroup.Tag value="android" label="Android" />
  </TagGroup.List>
  <TagGroup.Hint />
</TagGroup.Root>
Part Description
TagGroup.Root Manages selection mode ("none", "single", "multiple"), disabled keys, removal, controller attachment, and agent registration.
TagGroup.Label Group heading caption (hidden from duplicate screen-reader focus).
TagGroup.Hint Optional helper text for the group.
TagGroup.List Wrapping horizontal row container (role="group") for tags.
TagGroup.Tag Individual tag built on Chip.Root with selection, leading icon, and named remove action.

Usage

import { TagGroup } from "nitro-ui-sdk/tag-group";

<TagGroup.Root label="Topics" selectionMode="multiple" defaultValue={["design"]}>
  <TagGroup.Tag value="design" label="Design" />
  <TagGroup.Tag value="engineering" label="Engineering" />
  <TagGroup.Tag value="product" label="Product" />
</TagGroup.Root>;

Variants and sizes

variant, color, and size forward directly to each Chip: variant supports "primary", "secondary" (default), "tertiary", and "soft"; color supports "default" (default), "accent", "success", "warning", and "danger"; size supports "sm", "md" (default), and "lg".

<TagGroup.Root label="Status" variant="soft" color="accent" size="sm" selectionMode="single" defaultValue={["open"]}>
  <TagGroup.Tag value="open" label="Open" />
  <TagGroup.Tag value="closed" label="Closed" />
</TagGroup.Root>

States

  • Selection modes: "none" (display or remove-only), "single" (at most one active key), "multiple" (any subset of keys).
  • Removable: pass onRemove(key, details) on TagGroup.Root to render a named Chip.Remove button on each default tag. For custom tag children, use removeSlot={<Chip.Remove />} on TagGroup.Tag.
  • Disabled: pass disabled on TagGroup.Root, disabledKeys={["key"]} on TagGroup.Root, or disabled on an individual TagGroup.Tag.
<TagGroup.Root label="Platforms" selectionMode="multiple" disabledKeys={["web"]}>
  <TagGroup.Tag value="ios" label="iOS" />
  <TagGroup.Tag value="android" label="Android" />
  <TagGroup.Tag value="web" label="Web" />
</TagGroup.Root>

Controlled

Provide value (array of selected keys) and onValueChange to control selection. Calling details.preventDefault() declines the change.

import { useState } from "react";
import { TagGroup } from "nitro-ui-sdk/tag-group";

const [selected, setSelected] = useState<readonly string[]>(["swift"]);

<TagGroup.Root
  label="Languages"
  selectionMode="multiple"
  value={selected}
  onValueChange={setSelected}
>
  <TagGroup.Tag value="swift" label="Swift" />
  <TagGroup.Tag value="kotlin" label="Kotlin" />
  <TagGroup.Tag value="ts" label="TypeScript" />
</TagGroup.Root>;

Props

TagGroup.Root

Prop Type Default Description
label string — Required visible and accessible group name.
hint string undefined Optional helper text.
items readonly TagGroupItem[] Derived from Tag children Declarative tag list alternative to TagGroup.Tag children.
selectionMode "none" | "single" | "multiple" "none" Controls whether tags can be selected singly, multiply, or not at all.
value readonly string[] undefined Controlled selected tag keys.
defaultValue readonly string[] [] Initial uncontrolled selected tag keys.
onValueChange (keys: readonly string[], details: ActionDetails) => void undefined Called before selection changes.
onRemove (key: string, details: ActionDetails) => void undefined Enables removable tags and fires when a tag is removed.
removeConfirm Confirmation | ((item: TagGroupItem) => Confirmation | undefined) undefined Enables destructive agent actions on the group and eligible tags with a localized { message, approveLabel, cancelLabel }.
disabled boolean false Disables all tags in the group.
disabledKeys readonly string[] [] Keys of individual tags that cannot be selected or removed.
variant "primary" | "secondary" | "tertiary" | "soft" "secondary" Default Chip visual variant for tags.
color "default" | "accent" | "success" | "warning" | "danger" "default" Default Chip semantic color for tags.
size "sm" | "md" | "lg" "md" Default Chip size for tags.
styles PartStyles<TagGroupPart, TagGroupVariant, TagGroupSize, TagGroupState> undefined Per-part style overrides.
api Controller<TagGroupActions> undefined Imperative controller created with tagGroupPrimitive.createApi().
agentId string label Stable agent identity and scope ID.
layout SharedViewProps["layout"] undefined Additional layout props merged onto the root container.
children ReactNode Default <Label /> + <List /> + <Hint /> Custom part composition or direct TagGroup.Tag children.

TagGroup.Tag

Prop Type Default Description
value string — Unique item key.
label string — Visible and accessible tag title.
icon string undefined Optional SF Symbol rendered in Chip.Leading.
disabled boolean false Disables this individual tag.
removeLabel string `Remove ${label}` Accessible name for this tag’s remove button.
removeSlot ReactNode Chip default for default tag anatomy Explicit remove content beside the toggle. Use <Chip.Remove /> for custom tag anatomy.
variant TagGroupVariant Root variant Per-tag visual variant override.
color TagGroupColor Root color Per-tag semantic intent override.

Controller API

import { TagGroup, tagGroupPrimitive } from "nitro-ui-sdk/tag-group";

const api = tagGroupPrimitive.createApi();
<TagGroup.Root label="Topics" selectionMode="multiple" api={api}>
  <TagGroup.Tag value="ios" label="iOS" />
  <TagGroup.Tag value="android" label="Android" />
</TagGroup.Root>;
api.current?.toggle("ios");
Action Signature Result
select (key: string, source?: ActionSource) => ChangeStatus Adds key to selection (or replaces selection in "single" mode).
toggle (key: string, source?: ActionSource) => ChangeStatus Toggles key in or out of selection.
remove (key: string, source?: ActionSource) => ActionStatus Invokes onRemove(key, details) for an enabled tag.

Styles

Style resolvers receive { tokens, variant, size, state } where state is { disabled: boolean; selectionMode: TagGroupSelectionMode; value: readonly string[]; color: TagGroupColor }.

<TagGroup.Root
  label="Filters"
  selectionMode="multiple"
  styles={{
    list: ({ tokens }) => ({ layout: { gap: tokens.spacing.xs } }),
  }}
>
  <TagGroup.Tag value="new" label="New" />
</TagGroup.Root>

Accessibility

TagGroup.List uses Semantics role="group" with the group’s label. Each TagGroup.Tag delegates to Chip.Root (role="button" when selectable, with selected and disabled states) and exposes a named role="button" remove control (removeLabel or "Remove <label>") when removable using default anatomy or an explicit removeSlot. Touch toggles fire selectionChanged() haptics and touch removals fire impact("light") via Chip. Assistive and keyboard activation report details.source === "user" without haptics.

Agent API

Action Arguments Notes
select string (item key) Registered when selectionMode !== "none"; settles controlled updates.
toggle string (item key) Registered when selectionMode !== "none"; settles controlled updates.
remove string (item key) Registered on the group and per-tag chips only when both onRemove and a localized removeConfirm are supplied. Without removeConfirm, agents still see the tags and selection actions but no remove action.

Platform notes

iOS Android
Implementation Composed wrapping layout built on Chip and Semantics. Identical composed layout built on Chip and Semantics.
Verification Unit, type, iOS harness, and simulator screenshot verified. Shared TS/composed implementation; Android native build not run locally (no Android NDK on this machine).