dentil

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/badge
On this page
PaidOpenPast dueFailedVoidActiveDraft

Installation

pnpm dlx shadcn@latest add @dentil/badge
npx shadcn@latest add @dentil/badge
yarn dlx shadcn@latest add @dentil/badge
bunx --bun shadcn@latest add @dentil/badge

Files 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

Sizes

sm is the compact chip used in dense tables.

DefaultSmall

API reference

Badge

PropTypeDefaultDescription
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.
asChildbooleanfalseRenders the styles on the child instead of a span, for a link or button. The child must be one element, such as <a>.
classNamestring—Merged onto the badge.
…propsComponentProps<'span'>—Other span props, such as onClick and aria-invalid. aria-invalid draws the destructive ring.