Skip to content

Badge

Small labels for state, versions, plans and counts: six tones, three sizes, icons, clickable filters, a remove button, and BadgeGroup for +N overflow.

On this page
Used for
  • Run status
  • Plan labels
  • Model names
  • Beta flags
  • Removable filters

Examples

Badge or Tag? A badge describes something the system knows: a state, a version, a plan, a count. Its × is for occasional dismissing. A Tag holds values people type or pick, like filters, recipients or labels on a task. Tags come in a TagGroup with arrow-key focus, selection and Backspace to remove. If users build the list, use Tag.

Installation

npx knowns-ui@latest add badge
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"
Colour of the badge.
variant
"soft" | "outline" | "solid"
Default"soft"
Tinted fill, hairline outline, or solid fill for counts and highlights.
size
"sm" | "md" | "lg"
Default"md"
20, 22 or 26px high.
shape
"rounded" | "pill"
Default"rounded"
Softly rounded corners, or fully round ends.
dot
boolean
Defaultfalse
Leading dot in the tone colour.
icon
ReactNode
Leading glyph, logo (modelIcon) or tiny avatar, sized to the badge and hidden from screen readers.
onClick
(e) => void
Renders the badge as a button with a focus ring. Add aria-pressed for toggles.
onRemove
() => void
Adds a × button (its own tab stop). Never triggers onClick.
removeLabel
string
Default"Remove <label>"
Accessible name of the × button.
disabled
boolean
Defaultfalse
Dims the badge and disables its buttons.
...props
span / button attributes
className, title, aria-label, ref…
BadgeGroup max
number
Show at most this many badges; the rest fold into "+N" (never "+1"). Its tooltip lists them and a click shows all.
BadgeGroup size / shape
BadgeSize / BadgeShape
Default"md" / "rounded"
Look of the "+N" badge: match your badges.
BadgeGroup aria-label
string
Names the row (role="group").

What it handles

  1. 01Offers six tones (neutral, accent, info, success, warning, danger) in three looks: soft, outline and solid.
  2. 02Comes in sizes sm, md and lg and in a rounded or full `pill` shape, with an optional leading `dot` or `icon`.
  3. 03Becomes a button when you pass `onClick`, with a focus ring, and supports `disabled` for both click and remove.
  4. 04Adds a small remove button with `onRemove`, named "Remove <label>" by default or by `removeLabel`, and a click on it never fires `onClick`.
  5. 05Stacks badges in BadgeGroup and folds the overflow behind a "+N" button that lists the hidden labels and reveals them when pressed.
  6. 06Never folds a single badge, since "+1" is no shorter than the badge itself.

States

First render
Nothing. It paints as it is
none
Tone or variant change
Background, border and text colour change
180ms, ease out
Hover on the remove button
The button background deepens
120ms, ease out
Group expands
The hidden badges appear in place of the "+N" button
none
Reduced motion
Colour changes land at once
0ms

Works with

When to use

When to use

  • Short status labels in a tone, such as Active, Failed or Beta.

When not to use

  • Selectable or removable filters: use Tag.

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 Badge to my app and wire it to my own data.
  • I need short status labels in a tone, such as Active, Failed or Beta. Set that up with the Knowns UI Badge.
  • Which Badge props do I need for a minimal setup? Show me a short example.

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

Need help?

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