OutlineSecondaryMutedGhostInfoWarningSuccessDestructive
Installation
npx shadcn@latest add @assistant-ui/badgeThe @assistant-ui namespace resolves the Radix or Base UI flavor from your project's style through the style-aware registry entry in components.json. Without that entry, add by direct URL instead:
npx shadcn@latest add https://r.assistant-ui.com/base/badge.jsonMain Component
npm install @base-ui/react class-variance-authorityUsage
import { Badge } from "@/components/ui/badge";
export function Example() {
return <Badge>Label</Badge>;
}Examples
Variants
Use the variant prop to change the visual style.
OutlineSecondaryMutedGhostInfoWarningSuccessDestructive
<Badge variant="default" />
<Badge variant="secondary" />
<Badge variant="destructive" />
<Badge variant="outline" />
<Badge variant="ghost" />
<Badge variant="link" />With icons
Badges automatically style SVG icons.
SuccessFailedPending
As link
Compose with render in Base UI or asChild in Radix to render a badge as a link.
Animated
Combine the badge with CSS transitions for state changes.
LoadingMission SuccessLoadingMission Success
API Reference
Badge
BadgePropsvariant: "default" | "secondary" | "destructive" | "outline" | "ghost" | "link"= "default"The visual style of the badge.
render?: ReactElement | functionBase UI: compose as a different element.
asChild: boolean= falseRadix: merge props with a child element.
className?: stringAdditional CSS classes.
Style variants
| Export | Description |
|---|---|
badgeVariants | Styles for the badge component. |
import { badgeVariants } from "@/components/ui/badge";
<span className={badgeVariants({ variant: "secondary" })}>
Custom badge
</span>