Badge
FreeNewA short label for a status, a count or a category, in seven tones and two sizes, with an optional dot or icon.
Installation
pnpm dlx shadcn@latest add @viewport/badge
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above.
import { Check, Clock } from "lucide-react";
import { Badge } from "@/components/viewport/badge";
export default function BadgeDemo() {
return (
<div className="flex max-w-sm flex-col items-center gap-4">
<div className="flex flex-wrap items-center justify-center gap-2">
<Badge>Draft</Badge>
<Badge tone="outline">v2.4.0</Badge>
<Badge tone="solid">New</Badge>
<Badge tone="info" dot>
In review
</Badge>
<Badge tone="success">
<Check aria-hidden />
Paid
</Badge>
<Badge tone="warning">
<Clock aria-hidden />
Due in 3 days
</Badge>
<Badge tone="danger" dot>
Overdue
</Badge>
</div>
<div className="flex flex-wrap items-center justify-center gap-2">
<Badge size="sm">12</Badge>
<Badge size="sm" tone="solid">
99+
</Badge>
<Badge size="sm" tone="success" dot>
Active
</Badge>
<Badge size="sm" tone="outline">
Beta
</Badge>
</div>
</div>
);
}Props
| Prop | Type | Default |
|---|---|---|
| tone | keyof typeof tonesThe meaning of the badge. Never rely on the color alone: the text has to say it too. | "neutral" |
| size | "sm" | "md" | "md" |
| dot | booleanShow a dot in the text color before the label. | false |
Accessibility
- Text carries the meaning; the tone only supports it.
- Tabular numerals, so counts do not change width.
- Server component with no client JavaScript.