Skip to content
TopClass UI

Tag

A label chip for a topic, rendered on the server. Passing onRemove adds an x button, the only part that runs in the browser.

split - size not measured yet

Tag

split - size not measured yet

A label chip for a topic, rendered on the server. Passing onRemove adds an x button, the only part that runs in the browser.

Install
Design systems

Try it

tone
size

The code

tag.tsx
import { Tag } from 'topclassui/tag'

<Tag>Design systems</Tag>

A plain Tag stays on the server; onRemove is the switch that adds the x, and taking the tag out of the list is yours.

Every state

2 states
PlainRemovable

Import from the package

topclassui/tag
import { Tag } from 'topclassui/tag'

Install once:npm i topclassui@beta zod

Examples

  • For a topic, a category or a keyword, usually several in a wrapping row. For a status such as Paid or Overdue, use a Badge.
  • Tag has no ARIA role, so the text carries the meaning; colour alone never does. tone defaults to neutral, so a row of tags stays quiet.
  • The x only calls onRemove. A Server Component can pass it only as a Server Action; to keep the list in state, put it in a client component.
  • A Tag stays on one line: plain text ends in an ellipsis, an element given as the label is clipped at the edge, and the x always stays whole. In a row that does not wrap, add className="shrink" to let it shrink.
  • For a linked tag, put tagVariants() on the link itself and the label in a span of its own; never put a link inside a Tag.
topics
Design systemsAccessibilityReactTailwindRight to leftServer Components
tones
PrimaryNeutralSuccessWarningDangerInfo
sizes
Extra smallSmallMediumLargeExtra large
with-icon
VerifiedDraft
removable
  • Design systems
  • Accessibility
  • React
  • Tailwind
  • Right to left
  • Server Components
removable-sizes
Extra smallSmallMediumLargeExtra large
link
long-label
Infrastructure, platform reliability and developer experience working group
Infrastructure, platform reliability and developer experience working group
Infrastructure, platform reliability and developer experience working group
Infrastructure, platform reliability and developer experience working groupInfrastructure, platform reliability and developer experience working group
element-label
Infrastructure, platform reliability and developer experience working group
Infrastructure, platform reliability and developer experience working group
sha256_9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
custom-size
The scaleYour own row
In Arabic, right to left
موثّقتصميمإمكانية الوصولعاجل

Props

The props of Tag
PropTypeDefaultLimitsDescription
childrenReactNode--The label, and any icon beside it. The text carries the meaning; colour never does alone.
sizexs | sm | md | lg | xl | custom"md"-The shared size scale; custom emits no size classes.
toneprimary | neutral | success | warning | danger | info"neutral"-The meaning it signals, which picks the soft tint and its label colour.

Keyboard and accessibility

The keyboard of Tag
KeysWhat it does
TabMoves the focus to the x of a removable tag; a plain tag takes no focus.
EnterCalls onRemove.
SpaceCalls onRemove.
  • The x is named by its own word, then the label, so it reads "Remove React"; the word comes from the provider's labels ("إزالة" in Arabic).
  • A removed x takes the focus with it: send it to the next x, or the one before, and to a control after the list when it empties.
  • The x is 24 px, 44 under a touch pointer, with a visible focus ring.

Right to left

The padding is logical, so the x moves to the inline end and an icon to the inline start with no extra code.

Server and client

Renders on the server; the interactive part is a client component that ships only when it is used.

Files: index.tsx, client.tsx.

On the chip: split - size not measured yet.