Badge
A small pill-shaped status label built on a span, offering semantic tone colors, an optional monospace uppercase style, and a live indicator with a pulsing dot. It is a registry UI primitive from the usva registry that accepts all standard span HTML attributes.


Installed with plain
See how it was built shadcn add · no workarounds · theme neutral (none shipped)Installation
pnpm dlx shadcn@latest add @usva/badge
Requires @usva in the registries of your components.json (shadcn adds official directory namespaces automatically).
Usage
usage.tsx
import { Badge } from "@/components/ui/badge";export function Example() { return ( <Badge tone="success" mono> Deployed </Badge> );}- Showing a short status, state, or category label next to a title, row, or card (for example Active, Draft, Failed)
- Displaying a count or tag that needs a semantic color such as success, warning, or danger
- Marking something as currently streaming or running with the built-in pulsing live indicator
- Rendering compact uppercase monospace metadata such as version numbers, environment names, or IDs
Examples
Status tones
Semantic tones for common states in a list row.
status-tones.tsx
import { Badge } from "@/components/ui/badge";export function StatusRow() { return ( <div className="flex items-center gap-2"> <Badge tone="success">Active</Badge> <Badge tone="warning">Pending</Badge> <Badge tone="danger">Failed</Badge> <Badge>Draft</Badge> </div> );}Live indicator
Shows a pulsing dot to signal a running or streaming state.
live-indicator.tsx
import { Badge } from "@/components/ui/badge";export function LiveTag() { return ( <Badge tone="accent" live> Streaming </Badge> );}Monospace metadata tag
Uses the mono variant for version or environment labels.
monospace-metadata-tag.tsx
import { Badge } from "@/components/ui/badge";export function VersionTag() { return ( <Badge tone="accent-alt" mono aria-label="Version 2.4.1"> v2.4.1 </Badge> );}API reference
PropTypeDefaultDescription
tone"neutral" | "accent" | "accent-alt" | "success" | "warning" | "danger" | null | undefined"neutral"Semantic color tone applied through badgeVariants.
monoboolean | null | undefinedfalseSwitches to a monospace, semibold, uppercase, tightly tracked style.
liveboolean | undefinedundefinedWhen true, applies the live tone colors and renders a leading pulsing dot marked aria-hidden.
classNamestring | undefined—Additional classes merged with the variant classes via cn (tailwind-merge).
childrenReact.ReactNode—Label content rendered after the optional live indicator.
...propsReact.HTMLAttributes<HTMLSpanElement>—All other standard span attributes are forwarded to the root span element, such as id, role, aria-label, and event handlers.
Accessibility
- The root element is a span with no implicit role; add role="status" for dynamic status updates announced to assistive technology, or aria-label when the visible text is insufficient.
- The live pulsing dot is marked aria-hidden="true" so screen readers only read the label text.
- Color is not the only carrier of meaning when possible; include descriptive text such as Failed or Active rather than relying on the tone color alone.
- Ensure the chosen tone text color meets contrast requirements against the surface background in your theme.
- The animate-live-pulse animation should respect reduced-motion preferences; verify the project's keyframe definition includes a prefers-reduced-motion override.
Docs written by anthropic:claude-haiku-5-5 from the registry source.
Use with Coding Agent
Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.
prompt.md
Use the "Badge" component (usva/badge) from its shadcn registry.1. Install it with: npx shadcn@latest add @usva/badge2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: tone, mono, live, className, children, ...props.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { Badge } from "@/components/ui/badge";export function Example() { return ( <Badge tone="success" mono> Deployed </Badge> );}```Files & dependencies
- badge.tsx→ components/ui/badge.tsx
dependenciesclass-variance-authorityclsxtailwind-merge