Skip to content
GitHub

Badge

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

This is a Badge
import { Badge } from "@/components/ui/pxl/badge";
export default function BadgePreview() {
return (
<Badge>This is a Badge</Badge>
);
}
pnpm dlx shadcn@latest add pxl-ui/registry/badge
import { Badge } from "@/components/ui/pxl/badge"
<Badge variant="default">Badge</Badge>

Use the border prop to change the border style of the badge.

NoneDefaultOutlineNotch
import { Badge } from "@/components/ui/pxl/badge";
export default function BadgeBordersExample() {
return (
<div className="min-h-23 flex items-center justify-center">
<div className="flex flex-row flex-wrap gap-2.5">
<Badge variant="default" border="none">None</Badge>
<Badge variant="default" border="default">Default</Badge>
<Badge variant="primary" border="outline">Outline</Badge>
<Badge variant="default" border="notch">Notch</Badge>
</div>
</div>
);
}

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

XSSMMDLG
import { Badge } from "@/components/ui/pxl/badge";
export default function BadgeSizesExample() {
return (
<div className="min-h-23 flex items-center justify-center">
<div className="flex flex-row flex-wrap gap-2.5">
<Badge size="xs">XS</Badge>
<Badge size="sm">SM</Badge>
<Badge size="md">MD</Badge>
<Badge size="lg">LG</Badge>
</div>
</div>
);
}

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

PrimarySuccessDangerWarningInfoSecondaryGhostOutlineMutedAccent
import {
Badge
} from "@/components/ui/pxl/badge";
export default function BadgeVariantsExample() {
return (
<div className="min-h-23 flex items-center justify-center">
<div className="flex flex-row flex-wrap gap-2.5">
<Badge variant="primary">Primary</Badge>
<Badge variant="success">Success</Badge>
<Badge variant="danger">Danger</Badge>
<Badge variant="warning">Warning</Badge>
<Badge variant="info">Info</Badge>
<Badge variant="secondary">Secondary</Badge>
<Badge variant="ghost">Ghost</Badge>
<Badge variant="outline">Outline</Badge>
<Badge variant="muted">Muted</Badge>
<Badge variant="accent">Accent</Badge>
</div>
</div>
);
}

You can render an icon inside the badge. Use data-icon="inline-start" to render the icon on the left and data-icon="inline-end" to render the icon on the right.

You can render a spinner inside the badge. Remember to add the data-icon="inline-start" or data-icon="inline-end" prop to the spinner.

Use the render prop to render a link as a badge.

You can customize the colors of a badge by adding custom classes such as bg-green-50 dark:bg-green-800 to the Badge component.

The Badge component displays a badge or a component that looks like a badge.

Prop Type Default
variant "default" | "secondary" | "destructive" | "outline" | "ghost" | "link" "default"
className string -