Badge

Compact status or count label from @duo/ui.

Examples

Properties

PropertyAttributeDescriptionType nameTypeDefault
variantvariantColor variant (`primary`, `secondary`, `success`, …)DuoBadgeVariant"primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark""primary"
sizesize`s`, `m` (default), or `l`DuoBadgeSize"s" | "m" | "l""m"
pillpillFully rounded ends when truebooleanbooleanfalse
labellabelText when the default slot is emptystring | undefinedstring | undefined—

Slots

NameDescription
defaultBadge text; overrides `label` when provided.

Usage

Guidelines for designers and developers when using badges in product UI.

Do

  • Use variants consistently so people can learn what each color means (for example success vs. danger).
  • Use badges to reflect status or a small amount of metadata next to an object or in lists and tables.
  • Use the pill shape for numeric chips or compact counts when it fits the layout.
  • Prefer the default slot for label text; use the label attribute when you cannot slot content (for example in some templating setups).

Don’t

  • Don’t use a badge as the only way to complete a task—pair it with clear copy or actions where needed.
  • Don’t overload a single view with too many badges; prioritize the states that matter.
  • Don’t rely on color alone for meaning; the label should still read clearly (see WCAG 1.4.1 Use of Color).

Content guidelines

  • Prefer short labels, often a single word (for example “Shipped”, “Draft”, “Beta”).
  • Use sentence case: capitalize the first word; keep the rest lowercase unless it’s a proper noun.
  • For counts, keep them concise (3, 12+) and consider pill for a chip-like look.
  • Avoid long sentences inside a badge; if you need a full explanation, use supporting text or a Banner nearby.

Variants

NamePurpose
primaryDefault emphasis for general highlights or brand-forward status.
secondaryLower-emphasis or neutral-adjacent status compared to primary.
successPositive or completed outcomes.
dangerErrors, blocked states, or destructive context—use sparingly.
warningNeeds attention; may require follow-up but isn’t necessarily blocking.
infoInformational or neutral notices.
lightSubtle badge on darker or busy backgrounds.
darkStrong contrast on light backgrounds.

Sizes

Sizes s, m (default), and l adjust padding and type scale. Use s in dense tables or lists, m for default inline use, and l only when the badge must match larger surrounding text.