Skip to content

Tag

Short label that classifies or attributes content with a category or keyword. Optionally clickable or removable.

  • stable
  • since v0.1.0
  • 1.5 kB
  • feedback
  • label
  • metadata

Tag renders a <span> by default. With onClick, the whole tag becomes a <button>. With onRemove, the root becomes role="group" and the remove control is a separate focusable <button> labelled via removeLabel. Supports Backspace/Delete to remove when focused.

Preview
Open
tsx

Tag ships four variants — solid, soft (default), outline, and ghost — across six colour schemes (accent, neutral, success, warning, danger, info).

Preview
Open
tsx

Three sizes are available: xs, sm, and md (default).

Preview
Open
tsx

Pass any node to icon for a leading glyph. The icon is wrapped in an aria-hidden span so it stays decorative.

Preview
Open
tsx

Provide onClick to make the entire tag a button. Use this for filter chips that should respond to a single activation.

Preview
Open
tsx

Pass onRemove to render a dismiss control. The root becomes role="group", the remove button is keyboard reachable, and pressing Backspace or Delete on the focused group calls onRemove.

Preview
Open
tsx
PropTypeDefaultDescription
variant
"solid"|"soft"|"outline"|"ghost"
soft
Visual style. One of `soft`, `solid`, `outline`, `ghost`.
colorScheme
"accent"|"neutral"|"success"|"warning"|"danger"|"info"
neutral
Semantic palette. One of `neutral`, `accent`, `success`, `warning`, `danger`, `info`.
size
"xs"|"sm"|"md"
md
Pixel scale. One of `xs`, `sm`, `md`.
shape
"default"|"pill"|"square"
pill
Outline shape. `default` is gently rounded; `pill` is fully rounded; `square` has no corner rounding.
icon
ReactNode
Leading icon rendered before the children.
onRemove
(() => void)
Invoked when the user activates the trailing remove button.
onClick
(() => void)
Invoked when the tag itself is activated (click or keyboard).
removeLabel
string
Accessible label for the remove button. Defaults to `Remove {children}` when `children` is a string, otherwise `Remove`.
disabled
boolean
Disables the tag and its remove button, removing it from tab order.
children
ReactNode
Tag label content.
  • Static tags render as <span> — purely presentational.
  • Tags with onClick upgrade to <button> and inherit native button semantics.
  • Tags with onRemove render as role="group" with the focusable remove button labelled by removeLabel (defaults to Remove {label} when children is a string, otherwise Remove).
  • The group is tabIndex={0} so keyboard users can press Backspace or Delete to remove it without targeting the close button.
  • disabled propagates to the remove and click buttons and removes the group from tab order.
  • Use tags to classify articles, issues, or library entries with consistent colour.
  • Pair onClick with controlled filters to build a quick-filter row.
  • Provide removeLabel for non-string children so the remove action remains announced.
  • Use shape="square" for compact metadata strips and the default pill shape for prose contexts.