Badge
A compact label for status or category.
Overview
Badge is an inline label. It does not handle clicks. Compose it with a link, a spinner, or an icon when the label needs more than text.
className is merged after the variant, so Tailwind utilities can change the color without a new prop.
Preview
Customize
Installation
Add the component with the CLI. It copies the files in and installs anything they depend on.
npx vinyaas add badgeUsage
import { Badge } from "@/components/ui/badge";
export function Plan() {
return <Badge>Pro</Badge>;
}Examples
External link
The link variant is visual. Wrap it in an anchor when the label should navigate.
Processing
Put Spinner inside a badge when a status is still in progress. The badge text is the accessible name, so the spinner label stays empty.
Custom color
Badge supplies the shape and type size. className replaces the color with your own Tailwind classes.
Icon on the left
A leading icon can name the offer the badge describes.
Icon on the right
A trailing icon can show the action the label refers to.
Variants
Default, secondary, destructive, outline, ghost, and link cover status, quiet labels, and link-like text.
In practice
An issue board uses Badge variants as filters and row status labels.
Keyboard focus escapes Dialog
OpenTable scrolls on mobile
In progressToast dismiss race
BlockedDocs install path
Done
API
Other attributes for the underlying element are passed through.
| Name | Type | Default | Description |
|---|---|---|---|
variant | "default" | "secondary" | "destructive" | "outline" | "ghost" | "link" | "default" | Visual style. |
className | string | — | Merged onto the badge. Use it to extend the base styles with Tailwind classes. |
Accessibility
The text inside the badge is its name. It is not a button. Do not use color alone: the label should say the status.
Span attributes are passed through. When the badge sits inside a link, the link is the control and the badge stays presentational.