Badge
A small, non-interactive label for status or category. Six tints from the color system, three sizes, an optional dot or icon.
Usage
pnpm dlx shadcn@latest add badgeThen replace components/ui/badge.tsx with the Matrix version. It keeps shadcn's API and adds the status variants, sizes and the dot.
import { Badge, BadgeDot } from '@/components/ui/badge';
<Badge variant="success">Connected</Badge>
<Badge variant="warning">
<BadgeDot />
Needs review
</Badge>Variants
Each variant is one of the tint sets: a light fill, a matching edge and dark text, all above 6:1. Status colors carry meaning (teal success, gold warning, coral failure, blue information); brand and neutral label a category.
Sizes
md is the default. Match the badge to the text beside it: sm next to 12px metadata, md in lists and tables, lg next to 14px body text.
With dot
Online
Away
Offline
The dot takes the variant's solid status color, so it reads as live state. Use it for things that change on their own: presence, a running agent, a connection.
With icon
Verified
Attention
New
Icons are sized by the badge (12px, or 14px in lg) and take its text color. An icon plus a word works for everyone; color alone doesn't.
API reference
Prop
Type
shadcn's default, secondary and outline are accepted too and render the neutral badge.
BadgeDot takes no props of its own; its color follows the badge's variant.
Guidelines
- Write labels in sentence case, one or two words: "Needs review", not "Needs Review".
- Keep labels short, under about 20 characters; a badge never wraps.
- Pick the variant by meaning: success, warning, destructive and info for state; brand and neutral for category.
- Pair color with a word or an icon, never color alone.
- Don't use badges as buttons or links. For something people click or remove, use a tag.
- Don't color a badge by hand with
className; if no variant fits, the meaning probably needs a word instead.