Badge
A status chip or pill built from parts: a Badge, an optional BadgeTag chip in front, an optional BadgeDot, text and icons. Variant, color, size, radius and font are props; the tag and the dot pick their own colors. An optional tooltip makes it focusable.
- @ui-sdk/react
- class-variance-authority
Variants
import { Badge } from "@/components/ui/badge"
export function BadgeVariantsDemo() {
return (
<div className="flex flex-wrap items-center justify-center gap-2.5">
<Badge variant="solid">Solid</Badge>
<Badge variant="soft">Soft</Badge>
<Badge variant="outline">Outline</Badge>
<Badge variant="surface" color="muted">
Surface
</Badge>
</div>
)
}Colors
color takes every intent color. A BadgeTag has its own color and variant, so the chip and the badge can differ.
import { Badge, BadgeTag } from "@/components/ui/badge"
export function BadgeColorsDemo() {
return (
<div className="flex flex-col items-center gap-4">
<div className="flex flex-wrap items-center justify-center gap-2.5">
<Badge color="primary">Primary</Badge>
<Badge color="secondary">Secondary</Badge>
<Badge color="muted">Muted</Badge>
<Badge color="info">Info</Badge>
<Badge color="success">Success</Badge>
<Badge color="warning">Warning</Badge>
<Badge color="error">Error</Badge>
</div>
{/* The tag's color is its own: it never follows the badge's. */}
<div className="flex flex-wrap items-center justify-center gap-2.5">
<Badge variant="outline" color="info">
<BadgeTag color="success">Stable</BadgeTag>
v2.4.0
</Badge>
<Badge variant="soft" color="warning">
<BadgeTag color="warning">Beta</BadgeTag>
Agents API
</Badge>
<Badge variant="surface" color="muted">
<BadgeTag color="error" variant="soft">
Deprecated
</BadgeTag>
Legacy themes
</Badge>
</div>
</div>
)
}Shape and size
radius goes from square corners to a pill, and a BadgeTag inside follows it. size="sm" is the compact chip the docs use next to new components; font="mono" suits versions and codes.
import { Badge } from "@/components/ui/badge"
export function BadgeShapeDemo() {
return (
<div className="flex flex-col items-center gap-4">
<div className="flex flex-wrap items-center justify-center gap-2.5">
<Badge radius="none">None</Badge>
<Badge radius="sm">Small</Badge>
<Badge radius="md">Medium</Badge>
<Badge radius="full">Full</Badge>
</div>
<div className="flex flex-wrap items-center justify-center gap-2.5">
<Badge size="sm" radius="sm" font="mono">
NEW
</Badge>
<Badge size="sm" radius="sm" font="mono" color="info">
BETA
</Badge>
<Badge font="mono" variant="outline" color="muted">
v0.13.0
</Badge>
</div>
</div>
)
}Composition
Put a BadgeTag first and the badge tightens its start padding around it. Text, a BadgeDot and icons go in any order; icons are sized for you. render turns the whole badge into a link.
import { ArrowRight } from "lucide-react"
import { Badge, BadgeDot, BadgeTag } from "@/components/ui/badge"
export function BadgeCompositionDemo() {
return (
<div className="flex flex-col items-center gap-3">
<Badge variant="surface" color="muted" render={<a href="#composition" />}>
<BadgeTag>New</BadgeTag>
v0.13.0 · Badge is here
<ArrowRight aria-hidden="true" />
</Badge>
<Badge variant="surface" color="muted">
<BadgeTag>v0.13.0</BadgeTag>
<BadgeDot />
All operating systems
</Badge>
<Badge variant="outline" color="success">
<BadgeDot color="success" />
Operational
</Badge>
</div>
)
}Status dot
pulse rings the dot for live states, like a deploy in progress. The ring is off when the person prefers reduced motion, and the dot is always decorative: the text says the state.
import { Badge, BadgeDot } from "@/components/ui/badge"
export function BadgeDotDemo() {
return (
<div className="flex flex-wrap items-center justify-center gap-2.5">
<Badge variant="surface" color="muted">
<BadgeDot color="muted" />
Idle
</Badge>
<Badge variant="soft" color="info">
<BadgeDot color="info" pulse />
Deploying
</Badge>
<Badge variant="soft" color="error">
<BadgeDot color="error" pulse />
Live
</Badge>
</div>
)
}Tooltip
tooltip wraps the badge in the registry Tooltip, and tooltipOptions sets its side, alignment, offset, arrow and delay. A tooltip needs something focusable, so a badge without render becomes a button, and pressing it also shows the tip on touch screens. A link badge stays a link and is its own trigger.
import { Badge, BadgeTag } from "@/components/ui/badge"
export function BadgeTooltipDemo() {
return (
<div className="flex flex-wrap items-center justify-center gap-2.5">
<Badge color="warning" tooltip="May change before 1.0">
Beta
</Badge>
<Badge variant="outline" color="info" tooltip="Released on November 19" tooltipOptions={{ side: "bottom", arrow: false }}>
<BadgeTag color="success">Stable</BadgeTag>
v0.13.0
</Badge>
<Badge variant="surface" color="muted" render={<a href="#tooltip" />} tooltip="Jump to this section">
Link with a tip
</Badge>
</div>
)
}For full control, compose the parts: <TooltipTrigger render={<Badge render={<button type="button" />} />}>.
Installation
npx shadcn@latest add https://lanzate-ui.vercel.app/r/badge.jsonUsage
import { Badge, BadgeDot, BadgeTag } from "@/components/ui/badge"
// Compact chip
<Badge size="sm" radius="sm" font="mono">NEW</Badge>
// Announcement pill that links somewhere
<Badge variant="surface" color="muted" render={<a href="/changelog" />}>
<BadgeTag>New</BadgeTag>
v0.13.0 · Badge is here
</Badge>
// Live status
<Badge color="error">
<BadgeDot color="error" pulse />
Live
</Badge>
// With a tooltip
<Badge color="warning" tooltip="May change before 1.0">Beta</Badge>API
| Prop | Type | Default | Description |
|---|---|---|---|
Badge variant | "solid" | "soft" | "outline" | "surface" | "soft" | Fill style. surface is the neutral card pill (border, card fill, soft shadow); color only tints its text. |
Badge color | "primary" | "secondary" | "muted" | "info" | "success" | "warning" | "error" | "primary" | Intent color of the badge. A BadgeTag or BadgeDot inside keeps its own. |
Badge size | "sm" | "md" | "md" | sm is a compact chip, like a "New" next to a nav item; md is a pill with room for a tag, text and an icon. |
Badge radius | "none" | "sm" | "md" | "full" | "full" | Corner radius. A BadgeTag inside follows it. |
Badge font | "sans" | "mono" | Font family. Without it, the badge inherits the parent's. | |
Badge render | ReactElement | (props) => ReactElement | <span /> | Element to render instead of <span>, like render={<a href="…" />}. As a link or button it gets a hover fill and a focus ring. |
Badge tooltip | ReactNode | Wraps the badge in a Tooltip. Without render, the badge becomes a focusable button and the tip also toggles on press, for touch screens. | |
Badge tooltipOptions | { side, align, sideOffset, arrow, delay, toggleable, type, className } | Settings passed to the Tooltip and its content. For anything else, compose Tooltip and TooltipTrigger yourself. | |
Badge className | string | Classes merged after the variants, so they can override any base style. | |
BadgeTag color | "primary" | "secondary" | "muted" | "info" | "success" | "warning" | "error" | "primary" | Color of the leading chip, independent of the badge's. |
BadgeTag variant | "solid" | "soft" | "outline" | "solid" | Fill style of the chip. |
BadgeDot color | "primary" | "secondary" | "muted" | "info" | "success" | "warning" | "error" | "primary" | Color of the dot. |
BadgeDot pulse | boolean | false | Pulses a ring around the dot, for live states. Off when the person prefers reduced motion. |