Badge
Badges are compact, non-interactive labels used to highlight metadata, counts, or short categories.
Overview
The catnip-badge custom element provides seven semantic intents, subtle and strong appearances, three sizes, and optional icons on either side of its label.
| Prop | Role |
|---|---|
intent | Semantic color: neutral, informative, success, warning, danger, disabled, brand |
appearance | subtle uses a wash; strong uses a solid surface |
size | s, m, or l; a one-icon badge is square at 20px, 24px, or 28px |
leftIcon, rightIcon | Typed CatnipIconName values; named slots accept custom icon content |
badgeAriaLabel | Accessible name when the default slot is empty (required for icon-only) |
Live example
Guidelines
When to use
- Use Badge for short metadata such as “New”, “Beta”, a count, or a compact category.
- Use
appearance="strong"when the badge needs stronger emphasis against its surrounding surface. - Keep labels concise so badges remain easy to scan.
When not to use
- Use Status for a persistent state such as Active, Pending, or Failed.
- Use Chip for removable or selectable values.
- Use Alert for a message that needs attention or announcement semantics.
- Do not use the disabled intent to imply native disabled behavior; Badge is never interactive.
Icons
Use a Catnip icon prop for standard glyphs:
html
<catnip-badge intent="success" left-icon="tick">Verified</catnip-badge>Icon-only — badgeAriaLabel (HTML: badge-aria-label) is required:
html
<catnip-badge intent="warning" left-icon="plus" badge-aria-label="Add"></catnip-badge>A badge containing one icon and no label renders as a square: 20px at S, 24px at M, and 28px at L. Supplying both icon positions creates a wider badge rather than an icon-only square.
Use named light-DOM slots for custom artwork:
html
<catnip-badge appearance="strong" intent="brand">
<img slot="leftIconSlot" src="/brand-mark.svg" alt="" />
Partner
</catnip-badge>