View fulldotdev/ui on GitHub

Badge

Displays a badge or a component that looks like a badge.

Installation

npx shadcn@latest add @fulldev/badge

Usage

import { Badge } from "@/components/ui/badge"
<Badge variant="default">Badge</Badge>

Badge renders a span. It is strict polymorphic: pass as to render another element and use that element’s attributes, such as <Badge as="a" href="/docs"> or <Badge as="button" type="button">. badgeVariants gives the same classes to a custom element.

Variants

Use the variant prop to change the variant of the badge.

With Icon

Add data-icon="inline-start" or data-icon="inline-end" to the icon for the correct spacing.

With Spinner

Render a Spinner inside the badge with data-icon="inline-start" or data-icon="inline-end".

Use as="a" with href to render the badge as a link.

Custom Colors

Add classes such as bg-green-50 dark:bg-green-800 to customize the colors.

RTL

API Reference

Source: src/components/ui/badge

PropTypeDefault
variant"default" | "secondary" | "destructive" | "outline" | "ghost" | "link""default"
asHTML tag"span"

Badge writes its variant to data-variant.