Skip to main content

Badge

StorybookView in Storybook

Explore interactive examples and all component variations in our Storybook.

The Badge component displays labels, status indicators, counters, and other highlighted information in a compact format. It offers different visual variants for various contexts and is perfect for tags, notifications, and status indicators.

Basic Usage

Default Badge

Variants

Default
Secondary
Destructive
Outline

With Icons

Favorite

Approved

Rejected

Pending

Order Status

Order #1234
Pending
Order #1235
Processing
Order #1236
Shipped
Order #1237
Delivered
Order #1238
Cancelled

Category Tags

Technologies

React
TypeScript
JavaScript
CSS
HTML
Node.js
Next.js
Tailwind
UI/UX
Frontend

Notification Counters

3

12

5

2

User Roles

JS

John Smith

john@example.com

Administrator
SJ

Sarah Johnson

sarah@example.com

Editor
MW

Mike Wilson

mike@example.com

Viewer
ED

Emma Davis

emma@example.com

Administrator

Interactive Badges

Removable Tags

React
TypeScript
Tailwind
Next.js

Properties

Badge

PropertyTypeDefaultDescription
variant"default" | "secondary" | "destructive" | "outline""default"Visual variant of the badge.
classNamestring-Additional CSS classes.
childrenReactNode-Badge content.

Variants

VariantDescriptionRecommended Use
defaultPrimary badge with colored backgroundActive status, important information
secondaryBadge with light gray backgroundTags, categories, neutral information
destructiveRed badge for alertsErrors, critical status, destructive actions
outlineBadge with border, transparent backgroundPending status, secondary information

Features

Visual Flexibility

  • Multiple variants for different contexts
  • Support for icons and custom content
  • Easy customization with Tailwind CSS

Compact Design

  • Optimized for small spaces
  • Small but readable text
  • Appropriate padding for different content

Versatility

  • Works as label, status, counter
  • Can be interactive or informational only
  • Integrates well with other components

Common Use Cases

The Badge component is perfect for:

  • Tags and Categories - Content categorization and organization
  • Status Indicators - Order status, process states, progress indicators
  • Notifications - Message counters, visual alerts, activity indicators
  • Roles and Permissions - Access levels, user types, organizational hierarchies
  • Product Labels - New, sale, featured, out of stock indicators
  • Priority Levels - High, medium, low priority indicators
  • Content Metadata - Author roles, publication status, content types

Best Practices

  1. Use appropriate variants - Choose variants based on context and importance
  2. Keep text concise - Badges should contain brief and clear information
  3. Be consistent - Use the same variants for similar contexts
  4. Consider contrast - Ensure text is readable against the background
  5. Test responsiveness - Check how badges behave on small screens
  6. Use sparingly - Too many badges can clutter the interface
  7. Provide context - Make sure the badge meaning is clear to users