Badge

React Badge components are used to display small labels, counts, status indicators, or metadata with semantic colors and optional icons. They are commonly used for notifications, categories, tags, and metadata across interfaces.

This Badge component is built with React and styled using Tailwind CSS, giving developers control over size, color, and icon placement.

VerifiedActivePending

Installation

Install the component using the Tailgrids CLI.

npx @tailgrids/cli@latest add badge

Usage

Import the component and pass the required props.

import { Badge } from "@/components/tailgrids/badge";

export const BadgeExample = () => <Badge variant="default">New</Badge>;

Examples

Sizes

Badge component supports three predefined sizes: sm, md, and lg.

SmallMediumLarge

Variants

The variant prop selects the badge style: default, secondary, destructive, success, warning, outline, ghost and link. For other colors, pass Tailwind palette classes through className.

DefaultSecondarySuccessWarningDestructiveOutlineGhostLink

With Icons

Add icons before or after your text using the leadingIcon and trailingIcon props.

VerifiedRemovableActivePending

Custom

Use custom styles or positioning to create unique badges for specific use cases.

Outline BadgeSquare BadgeGradient Badge

API Reference

Badge

Extends span element props.

PropTypeDefaultDescription
size'sm' | 'md' | 'lg''sm'Sets the badge size
variant'default' | 'secondary' | 'destructive' | 'success' | 'warning' | 'outline' | 'ghost' | 'link''default'Sets the badge style
leadingIconReact.ReactNode-Icon before the text
trailingIconReact.ReactNode-Icon after the text
classNamestring-Additional CSS classes
childrenReact.ReactNode-Badge content

Notes

  • Icons are automatically sized to 12px (0.75rem) via the [&>svg]:size-3 class
  • Padding adjusts automatically based on the presence of prefix/suffix icons
  • All standard span HTML attributes are supported

On this page

Tailgrids Pro

Access 600+ blocks, components and templates - built for speed, consistency, and scale.

Get Tailgrids Pro