Badge
Badge labels a status. The first letter is capitalized, so paid reads as Paid. Green, amber, red and zinc keep their hue in any theme. default, secondary and outline follow the theme. Active uses size="sm", and Draft is the badge rendered as a link.
@dentil/badgeOn this page
components/demos/badge-overview.tsx
'use client';
import { Badge } from '@/components/dentil/badge/badge';
export function BadgeOverviewDemo() {
return (
<div className="flex flex-wrap items-center gap-2">
<Badge variant="green">paid</Badge>
<Badge variant="blue">open</Badge>
<Badge variant="amber">past due</Badge>
<Badge variant="red">failed</Badge>
<Badge variant="zinc">void</Badge>
<Badge variant="green" size="sm">
active
</Badge>
<Badge variant="outline" asChild>
<a href="#examples">draft</a>
</Badge>
</div>
);
}Installation
pnpm dlx shadcn@latest add @dentil/badgenpx shadcn@latest add @dentil/badgeyarn dlx shadcn@latest add @dentil/badgebunx --bun shadcn@latest add @dentil/badgeFiles land in components/dentil/badge/. It has no shadcn dependencies. asChild uses Radix Slot.
Usage
Pass the status in lowercase. An icon inside is 12px. asChild puts the same styles on a link.
import { Circle } from 'lucide-react';
import { Badge } from '@/components/dentil/badge/badge';
<Badge variant="green">
<Circle className="fill-current" />
paid
</Badge>
<Badge variant="amber" size="sm">past due</Badge>
<Badge variant="blue" asChild>
<a href="/invoices/in_123">open</a>
</Badge>Examples
Colors
Theme variants first, then the fixed hues.
DefaultSecondaryOutlineDestructiveRedOrangeAmberYellowLimeGreenEmeraldTealCyanSkyBlueIndigoVioletPurpleFuchsiaPinkRoseZinc
components/demos/badge-colors.tsx
'use client';
import { Badge, type BadgeVariant } from '@/components/dentil/badge/badge';
const variants = [
'default',
'secondary',
'outline',
'destructive',
'red',
'orange',
'amber',
'yellow',
'lime',
'green',
'emerald',
'teal',
'cyan',
'sky',
'blue',
'indigo',
'violet',
'purple',
'fuchsia',
'pink',
'rose',
'zinc',
] as const satisfies readonly NonNullable<BadgeVariant>[];
export function BadgeColorsDemo() {
return (
<div className="flex flex-wrap gap-2">
{variants.map((variant) => (
<Badge key={variant} variant={variant}>
{variant}
</Badge>
))}
</div>
);
}Sizes
sm is the compact chip used in dense tables.
DefaultSmall
components/demos/badge-sizes.tsx
'use client';
import { Badge } from '@/components/dentil/badge/badge';
export function BadgeSizesDemo() {
return (
<div className="flex items-center gap-2">
<Badge>default</Badge>
<Badge size="sm">small</Badge>
</div>
);
}API reference
Badge
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | 'default' | 'secondary' | 'destructive' | 'outline' | 'red' | 'orange' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose' | 'zinc' | 'default' | default is a muted fill, secondary uses the secondary token, and outline is text with an accent hover when the badge is a link. destructive uses the theme's destructive tint. The named colors are fixed Tailwind hues, so a paid badge stays green when the theme changes. A parent with className="group" and data-hover deepens a named color. |
| size | 'default' | 'sm' | 'default' | default is padded text. sm is 19px tall with tighter horizontal padding. |
| asChild | boolean | false | Renders the styles on the child instead of a span, for a link or button. The child must be one element, such as <a>. |
| className | string | — | Merged onto the badge. |
| …props | ComponentProps<'span'> | — | Other span props, such as onClick and aria-invalid. aria-invalid draws the destructive ring. |