Badge Properties

Compact UI elements that highlight status, labels, or counts with various styles and colors. Customizable in size and appearance with support for disabled states.

Preview

Default

Installation

Install the following dependencies

Run these commands in your terminal to install the required packages

Terminal
Loading syntax highlighting...

Create or update your Badge component

Copy this code to create your Badge component

/components/ui/Badge.tsx
Loading syntax highlighting...

Test Your Component

  • 1. Add the component to a test page
  • 2. Check all props and variants work as expected
  • 3. Verify responsive behavior
  • 4. Test with different content/data
  • 5. Ensure accessibility features work correctly

Colors and Styles

The Badge component supports various colors and styles to suit different UI contexts. Each style is available in multiple colors.

filled Style

The primary style for badges, offering high contrast and visibility.

gray
blue
orange
red
green
yellow
purple
sky
pink
teal

light Style

A softer variant that maintains color association while reducing visual weight.

gray
blue
orange
red
green
yellow
purple
sky
pink
teal

lighter Style

A softer variant that maintains color association while reducing visual weight.

gray
blue
orange
red
green
yellow
purple
sky
pink
teal

stroke Style

An outline style that provides a subtle yet distinct appearance.

gray
blue
orange
red
green
yellow
purple
sky
pink
teal

Rounded vs Default

Badges can have either rounded or square corners. Use the 'rounded' prop to switch between these styles.

Default
Rounded
2
2
22
22
257
257

Badge Sizes

Badges come in two sizes: default (h-5) and small (h-4). Use the 'size' prop to switch between these sizes.

medium Badge
small Badge

Badges with Icons

Icons can be added to badges to provide additional visual cues. Icons can be positioned on the left or right side of the badge text.

left icon
left icon
left icon
right icon
right icon
right icon

Badges with Dots

Dots can be used instead of icons for a more subtle indicator. They're particularly useful for status indicators or notifications.

Badge
Badge

Status Badges

Status badges are used to indicate different states or levels of importance. They come with predefined colors and can be displayed with icons or dots in both rounded and default styles.

Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge

Custom Badge

You can create a custom badge with full class override capabilities.

Custom

Rounded Badges

Rounded badges provide a softer look with fully rounded corners, ideal for modern UI designs.

gray
blue
orange
red
green
yellow
purple
sky
pink
teal

API Reference

The Badge component provides a versatile way to display short status descriptors in your interface. It uses Radix UI's Slot primitive for composition when the asChild prop is used.

Badge.Root

Main badge component with support for various styles, colors, and sizes.

PropTypeDefaultDescription
size
"small""medium""lg""string"
"small"

Size of the badge

variant
"filled""light""lighter""stroke""default""secondary""outline""destructive"
"filled"

Visual style variant of the badge

color
"neutral""gray""blue""orange""red""green""yellow""purple""sky""pink""teal"
"neutral"

Color theme of the badge

disabled"boolean""false"

Whether the badge is in a disabled state

square"boolean""false"

Whether to use square (minimal) padding

rounded"boolean""false"

Whether to use fully rounded corners (pill shape)

asChild"boolean""false"

Whether to merge props onto child component

Badge.Icon

Adds an icon to the badge with proper sizing and alignment.

PropTypeDefaultDescription
as"ReactElement""undefined"

Icon component to render

size
"small""medium""string"
"small"

Size of the icon

Badge.Dot

Displays a small dot indicator within the badge for status representation.

PropTypeDefaultDescription
size
"small""medium""string"
"small"

Size of the dot indicator