Tag
Tag - An interactive pill component for selection, filtering, and multi-select scenarios.
Uses shared pill styling (identical to Badge) with interactive capabilities:
dismissibility, click handling, and keyboard support.
The outer element is polymorphic based on interactivity:
- onClick provided: <button>
- onDismiss only: <div> with dismiss <button>
- Both: <div> with separate selection and dismiss <button> elements
- Neither: <span> (presentational)
Usage
Best practices
Choose
Tagwhen the chip is interactive (selection/filter/dismiss); for a display-only status label or count useBadge, and for a bare colour dot useDot.Pass
onClickfor selection andonDismissfor removal. When both are provided they render as sibling buttons inside one visual chip; don't wrap Tag in another button.With both actions, HTML attributes (including the accessible name and selected state) apply to the selection button;
classNameandstylestyle the outer chip.Set at most one leading visual -
loading>imageUrl>dot>icon(in that precedence); pass a Lucide component toicon(not<Icon/>), andimageUrlrenders a circular<img alt="">, so keep it decorative.When
onDismissis set, Backspace/Delete also removes the tag while it's focused - don't bind your own conflicting key handler.
Props
Also exports
- const
TAG_SIZES - const
TAG_TONES - type
TagEmphasis - interface
TagProps - type
TagSize - type
TagTone