Skip to content
TopClass UI

Badge

A short status label in three variants across six tones. It renders on the server and ships no JavaScript.

server - 0 KB

Badge

server - 0 KB

A short status label in three variants across six tones. It renders on the server and ships no JavaScript.

Install
Paid

Try it

variant
tone
size

The code

badge.tsx
import { Badge } from 'topclassui/badge'

<Badge>Paid</Badge>

Badge has no ARIA role: the text carries the meaning, colour never does alone.

Every state

3 states
SolidSoftOutline

Import from the package

topclassui/badge
import { Badge } from 'topclassui/badge'

Install once:npm i topclassui@beta zod

Examples

  • For a short status beside the thing it describes: Paid, Pending, Draft, a count. It is a label, not a control; for something the user can remove or press, use a Tag or a Button.
  • A long label truncates to its container with an ellipsis instead of wrapping.
  • BadgeSkeleton holds its place at the same height while data loads; give it the size of the badge it stands in for.
  • size="custom" emits no size classes, so className sets the padding and the type step.
with-icon
PaidPendingOverdue
variants
SolidSoftOutline
tones
PrimaryNeutralSuccessWarningDangerInfo
PrimaryNeutralSuccessWarningDangerInfo
PrimaryNeutralSuccessWarningDangerInfo
sizes
Extra smallSmallMediumLargeExtra large
long-label
Awaiting a second approval from the finance team before release
Awaiting a second approval from the finance team before release
Awaiting a second approval from the finance team before release
skeleton
Small
Medium
Large
custom-size
The scaleYour own row
In Arabic, right to left
مدفوعقيد الانتظارمتأخرمسودة

Props

The props of Badge
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"primary"-The meaning it signals, which picks its colour ramp.
variantsolid | soft | outline"soft"-How loudly the badge stands out: a fill, a tint or an outline.

Keyboard and accessibility

Nothing to operate: it is not interactive on its own.

  • Badge is not focusable and has no role, so a screen reader reads its text as part of the sentence around it.
  • Write the status in words: Paid, Overdue. A tone alone says nothing to someone who cannot see the colour.
  • An icon beside the text is decoration; the word carries the status.

Right to left

The icon and the text swap sides with the reading direction, and a cut label keeps its ellipsis at the end of its own direction.

Server and client

Renders on the server and ships no JavaScript.

Files: index.tsx.

On the chip: server - 0 KB.