Join our Discord Community

Shadcn Badge

React badge component for status indicators, notification counts, and labels. Built with TypeScript and Tailwind CSS for Next.js using CVA variants.

Badge positioning off?

Join our Discord community for help from other developers.


Ever shipped a feature where every developer made their own badge style? Red here, blue there, rounded on this page, square on that one. Before you know it, your app looks like a bag of Skittles exploded. This shadcn/ui badge component brings sanity back to your status indicators.

Badge showcase

All badge variants in action:

Loading component...

Built with class-variance-authority (CVA) for type-safe variants and TypeScript autocompletion. Styled with Tailwind CSS so you can actually customize them without fighting the framework.

npx shadcn@latest add badge

Why badges actually guide attention

Here's the thing—badges aren't just colorful decorations. They're visual shortcuts that help users scan interfaces quickly. A red badge on an error? Users know something's wrong before reading a single word. A "99+" on your inbox? That's anxiety in a circle.

Think about GitHub's notification badge. You see that blue dot and you know exactly what it means—someone needs your attention. No explanation needed. That's the power of a well-placed badge in your React applications.

This free shadcn badge handles the visual consistency while you focus on the logic. Whether you're showing user roles, content tags, or notification counts in your JavaScript apps, badges that look consistent build trust.

Common badge patterns you'll actually use

Badge variants

Four styles for different contexts:

Loading component...

Badge with icons

Icons plus text for clearer communication:

Loading component...

Interactive badges

Clickable badges for filters and actions:

Loading component...

Badge shapes

Notification counts and special styles:

Loading component...

Features

This free open source badge component includes everything you need:

  • TypeScript variants - Type-safe props with full autocompletion
  • CVA powered - Consistent variants without the prop drilling nightmare
  • Tailwind CSS utilities - Override anything with className, no !important hacks
  • Icon support - Auto-sized icons with proper spacing built-in
  • Accessible by default - Proper color contrast and focus states
  • Composable design - Works inside buttons, cards, tables, anywhere
  • Size flexibility - From tiny notification dots to large status badges

API Reference

Badge

The badge component with variant support through CVA.

PropTypeDefaultDescription
variant"default" | "secondary" | "destructive" | "outline""default"Visual style variant for different contexts
classNamestring-Additional CSS classes for custom styling
childrenReact.ReactNode-Badge content (text, icons, or both)

Variant Styles

VariantUse CaseAppearance
defaultPrimary info, active statesSolid primary background
secondaryNeutral info, metadataMuted background
destructiveErrors, warnings, urgentRed/destructive theme
outlineSubtle tags, filtersBorder only, transparent

Built-in Features

FeatureDescriptionImplementation
Icon sizingAuto-scales icons[&>svg]:size-3 class
Focus ringKeyboard navigationFocus-visible utilities
Hover statesInteractive feedbackOpacity/color changes
ResponsiveScales with font sizeRelative units (em/rem)

Production tips

Keep badge text super short. This free shadcn/ui badge looks best with 1-2 words max. "NEW" beats "Recently Added Item". If you need more text, you probably want a different component.

Be consistent with colors. Don't use destructive for "Sale" just because it's red. Users learn that red means error in your Next.js app, then suddenly it means discount? That's confusing. Pick a color system and stick to it.

Notification counts need limits. Nobody cares about the difference between 847 and 848 unread messages. Cap it at "99+" or even "9+". Your TypeScript badge component should communicate urgency, not exact math.

Test color contrast. That lime green badge might look cool on your monitor, but can everyone read it? This open source shadcn component uses accessible defaults, but custom colors are on you.

Don't badge everything. When everything has a badge, nothing feels important. Use them for stuff that actually needs attention in your React applications.

Integration with other components

Badges shine when paired with Avatar components to show user status or roles in your React apps. Combine with Button components for actionable filters—click a badge to toggle a category.

Inside Table components, badges make status columns scannable at a glance. This open source pattern beats reading "Active", "Pending", "Active", "Error" down a column. When building navigation, badges on Tabs show counts without cluttering the interface.

For cards, throw badges in the corner of Card components to highlight featured content or sale items. Your JavaScript components stay clean while communicating important metadata.

Questions you might have