npx shadcn@4.23.1 add @goop/trail-badgeBadge
FreeA small pill with a word, an icon or a count, for a status, a tag or a label beside a title or in a row, for React and Tailwind CSS. Free, MIT.
What an agent sees
- BadgeIconThe badge's leading icon
- BadgeLabelThe status words in a Badge, after an optional BadgeIcon and before an optional BadgeValue
- BadgeValueThe badge's count (
<BadgeValue>{unread}</BadgeValue>, after its words or alone)
import { Badge, BadgeIcon, BadgeLabel, BadgeValue } from '@/components/ui/goop/badge';
<>
<Badge variant="success">
<BadgeIcon icon="circle-check" />
<BadgeLabel>Paid</BadgeLabel>
</Badge>
<Badge variant="warning">
<BadgeLabel>Due</BadgeLabel>
</Badge>
<Badge variant="outline">
<BadgeIcon icon="history" />
<BadgeLabel>To sync</BadgeLabel>
<BadgeValue>{3}</BadgeValue>
</Badge>
</>Switch the variant (each status with its icon), change the words, add a count and change it to see only its changed digits move. Nothing is saved: the badge is drawn live from the panel.
When to use
- A small pill with a word, an icon or a count, for a status, a tag or a label beside a title or in a row.
- Also called: tag, chip or pill.
Installation
Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Badge on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing.
npx shadcn@4.23.1 add @goop/trail-badgeAdd the Goop Badge to this project. The install steps are at https://goop.so/docs/install.mdUsage
import { Badge, BadgeIcon, BadgeLabel, BadgeValue } from '@/components/ui/goop/badge';
<>
<Badge variant="success">
<BadgeIcon icon="circle-check" />
<BadgeLabel>Paid</BadgeLabel>
</Badge>
<Badge variant="warning">
<BadgeLabel>Due</BadgeLabel>
</Badge>
<Badge variant="outline">
<BadgeIcon icon="history" />
<BadgeLabel>To sync</BadgeLabel>
<BadgeValue>{3}</BadgeValue>
</Badge>
</>- Fits: list, record: row.
- In a Table, give a column of badges the track
auto, never a guessed px width (a narrower track cuts a pill's words). In a grid of your own, anautotrack is exactly the pill's width: give its cellspe-6. - height, width, padding, corner, background, shadow, text, motion: add no class for these.
API reference
| Option | Type | What it does |
|---|---|---|
| variant | default | outline | success | warning | destructive | info = default | |
| asChild? | boolean = false | Render the badge's look on the one child element instead of a span (a link, a button). |
| Part | What it is |
|---|---|
| BadgeIcon | The badge's leading icon; icon: IconName — A pack icon name |
| BadgeLabel | The status words in a Badge, after an optional BadgeIcon and before an optional BadgeValue |
| BadgeValue | The badge's count (<BadgeValue>{unread}</BadgeValue>, after its words or alone) |
- Class recipes (cva): badgeVariants (Badge)
- data-slot values (to select a part by): badge, badge-icon, badge-label, badge-value, badge-value-item
Accessibility
- hover, active, focus-visible: the browser's own (:hover, :active, :focus-visible): write nothing
Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:
| State | Drawn by |
|---|---|
| disabled | the prop disabled |
Motion
- The part sets its own motion: add no transition or animation of your own.
- How the theme moves, and how to move your own parts the same way: Motion.
Notes for AI
Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.