UI.MD

Badge

A small status indicator with multiple semantic variants.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/badge.json

Usage

import { Badge } from "@/components/ui/badge"

Examples

Default

Default

Variants

The six semantic variants. muted and outline draw a hairline edge instead of a fill, so they stay quiet beside a badge carrying a real status color.

DefaultSuccessWarningDestructiveMutedOutline

Sizes

The three annotation sizes step 11 / 12 / 13px, each a step below the control type around it, so a badge reads as a label rather than a button. lg is the ceiling for a badge that annotates something.

SmallDefaultLarge

Display

display is a different job, not the next step up: a featured stat in a chip on a marketing surface, like a subscriber count in a hero. It jumps to 16px, skipping body size. Keep it off control rows and card corners, where the 13px annotation ceiling holds.

12,480 subscribersEst. 2019

With Icon

icon takes an element (<Star />), not a bare component reference. It scales with the badge size, so there is never a size to set on the icon itself.

FeaturedActivePendingFailedDraftLabel

API Reference

PropTypeDefaultDescription
variant"default" | "success" | "warning" | "destructive" | "muted" | "outline""default"Semantic variants tint the background and text; outline renders bordered and transparent.
size"sm" | "default" | "lg" | "display""default"Scales padding, text, and icon size together: sm is 11px text, default 12px, lg 13px. Those three sit a step below the control type around them, so a badge reads as a label rather than a button. display (16px) is for a featured stat on a marketing surface, not for annotating controls.
iconReact.ReactNode-Optional icon element rendered before the label, e.g. <Star />. Scales with the badge size.