Shadcn Badge
React badge for status, counts, and labels. Built with TypeScript and Tailwind CSS for Next.js using Base UI — six variants, icons, and render links on a span.
A badge is a compact label for status, a count, or a tag. It is a span. Use render={<a href="…" />} for a link. Keep the text to a word or two.
Looking for a neobrutalism version for shadcn?
Same badge, thicker borders. The NeoBrutalism badge is the kit if you want that look.
Usage
import { Badge } from "@/components/ui/badge"<Badge variant="secondary">Beta</Badge>variant is default, secondary, destructive, outline, ghost, or link. render={<a href="…" />} makes it a link.
Composition
render={<a href="…" />} merges the badge onto the link. Switch to Radix UI for asChild.
Variants
variant picks the color. Ghost is quiet; destructive is the red one.
With Icon
data-icon="inline-start" or data-icon="inline-end" so the icon stays on the reading-start or reading-end side.
With Spinner
Same data-icon attributes on Spinner. Pair it with a word — Deleting, Generating — not a bare spinner.
Link
render={<a href="…" />} plus the label as children. Hover comes from the [a&] selectors on the variants.
Custom Colors
Class names on Badge — bg-green-50 text-green-700 dark:bg-green-950 dark:text-green-300. Leave variant at default.
RTL
Wrap with DirectionProvider and dir="rtl". Keep data-icon="inline-start" / inline-end so icons flip with the text.
API
Prop
Type
Notes
Give counts a name
A badge that says 3 is silent context. aria-label="3 unread messages" or an sr-only span. Same for icon-only badges.
Keep the label to a word or two. A sentence belongs in an Alert.
With other components
Role next to the photo
ButtonCount on the trigger
TableStatus in a cell
TabsUnread on a tab
CardFeatured in the header
InputTag on a filter
Questions
Related
Was this page helpful?
Sign in to leave feedback.
Avatar
React avatar for profile photos, comments, and team lists. Built with TypeScript and Tailwind CSS for Next.js using Base UI — image, fallback, badge, and groups.
Breadcrumb
React breadcrumb for docs and store category trails. Built with TypeScript and Tailwind CSS for Next.js using Base UI — Slot links, custom separators, collapsed paths.