Badge
Badge
A status, a tag or a count: statuses ease their colour and morph their word, live dots breathe, counts roll and fold away at zero.
Dependencies
Interaction states
- status change — Colours ease (300ms) and the word morphs letter by letter.
- live — With dot="pulse", a ring scales out of the dot and fades (1.6s loop).
- count — Digits roll the way the count moved; at 0 the badge folds away (320ms) unless showZero.
Installation
Add this component with your preferred package manager.
pnpm dlx shadcn@4.21.5 add @cavemio/badgeFirst install? Configure @cavemio once
Run npx shadcn@4.21.5 init if shadcn is not set up, then merge this entry into the registries field in your existing components.json. Keep your other settings and registries.
{
"registries": {
"@cavemio": "https://registry.cavemio.dev/r/cavemio-{name}.json"
}
}Where it’s used
Invoice and order tables
Paid, Pending, Overdue in a status column.
Deploy and build lists
A breathing "Building" dot that settles to "Ready".
Navigation
Unread counts on Inbox and Mentions.
Tags
Plan, role or category labels in outline.
What it handles
- Tone changes ease — Background, text and dot colours transition (300ms) as the word morphs.
- Counts that roll — NumberRoll digits, 99+ cap, fold away at zero.
- Live dot — A ring breathes out from the dot every 1.6s.
- Five tones, two looks — neutral, primary, success, warning, danger; filled or outline.
Usage
Interactive local fixture. Data and async results are simulated in the preview; the caller supplies application services.
import { Badge } from "@/components/badge";
<Badge tone={paid ? "success" : "warning"} dot>{paid ? "Paid" : "Pending"}</Badge>
<Badge tone="primary" count={unread} />Props
| Prop | Type | Description |
|---|---|---|
| children | string | – · The word. |
| tone | "neutral" | "primary" | "success" | "warning" | "danger" | "neutral" · Colour. |
| outline | boolean | false · thin line only. |
| dot | boolean | "pulse" | – · A dot before the text; "pulse" breathes. |
| count / max / showZero | number / number / boolean | – · A rolling number instead of text. |
| icon | ReactNode | – · A 12px icon. |
| size | "sm" | "md" | "md" · 20px or 24px. |
Accessibility & motion
- Reduced motion: no breathing ring, the count changes in place. - Status colours always come with a word, never colour alone.
pnpm dlx shadcn@4.21.5 add @cavemio/badge