Skip to content

Tag

Quiet chips for filters, labels and context. Groups can be selectable and removable, with arrow-key focus and Delete to remove.

On this page
Used for
  • Active filters
  • Ticket labels
  • Prompt categories
  • Recipient chips

Examples

Installation

npx knowns-ui@latest add tag
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

tone
"neutral" | "accent" | "info" | "success" | "warning" | "danger"
Default"neutral"
Tints the ring, the dot and a whisper of fill. Text stays neutral.
dot / icon / avatar
boolean / ReactNode / ReactNode
Leading mark: a tone dot, a 12–14px glyph, or a tiny round avatar or logo.
count
number
Muted number after the label.
onRemove
() => void
Shows an × button.
removeLabel
string
Default"Remove <label>"
Accessible name of the × button.
size
"sm" | "md"
Default"md"
24 or 28px high.
TagGroup.items
TagItem[]
{ id, label, textValue?, tone?, dot?, icon?, avatar?, count?, disabled?, removable? }
TagGroup.aria-label
string
Required name for the list.
TagGroup.selectionMode
"none" | "single" | "multiple"
Default"none"
none: role="list"; single / multiple: role="listbox" with options and aria-selected. One tab stop; ← → Home End move.
TagGroup.value / defaultValue / onValueChange
string[]
Default[]
Selected ids, controlled or not. Single mode toggles off when the selected tag is picked again.
TagGroup.onRemove
(ids: string[]) => void
Makes tags removable (× with the mouse, Backspace or Delete from the keyboard). Focus moves to the next tag.
TagGroup.max
number
Show this many, then a "+N more" button. Never "+1 more".

What it handles

  1. 01Draws a quiet chip with an optional `dot`, `icon`, `avatar` and a muted `count` after the label.
  2. 02Comes in six tones and two sizes, sm and md, and takes `selected` and `disabled` looks.
  3. 03Shows a remove button with `onRemove`, named "Remove <label>" unless `removeLabel` says otherwise.
  4. 04Groups tags in TagGroup with roving focus: left and right arrows, Home and End move between tags.
  5. 05Selects in TagGroup with `selectionMode` single or multiple as a listbox, where Space or Enter toggles a tag.
  6. 06Removes the focused tag on Backspace or Delete, moves focus to the next one, and shows at most `max` tags with a "+N more" button.

States

First render
Nothing. It paints as it is
none
Select or deselect
Background, ring and text colour change
180ms, ease out
Hover on the remove button
The button background deepens
120ms, ease out
Tag removed
The tag leaves at once and focus moves on
none

Works with

When to use

When to use

  • Quiet chips the user selects or removes, such as filters or labels on an item.

When not to use

  • A read-only status: use Badge.

Using with AI

Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:

  • Add the Knowns UI Tag to my app and wire it to my own data.
  • I need quiet chips the user selects or removes, such as filters or labels on an item. Set that up with the Knowns UI Tag.
  • Which Tag props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "tag" }) and search_docs({ query: "tag" }).

Need help?

Stuck on Tag, or found something off? We read every message.