GitHub

Badge

A small pill for counts, statuses, and labels. Six color intents, three sizes, plus a dot mode for compact status indicators.

Stable .astro import EsaBadge from '@esa/ecology/esa-badge.astro';

Preview

New
<Badge value="New" />

Variants

Primary Secondary Success Warning Danger Info
<Badge value="Primary" variant="primary" />
<Badge value="Secondary" variant="secondary" />
<Badge value="Success" variant="success" />
<Badge value="Warning" variant="warning" />
<Badge value="Danger" variant="danger" />
<Badge value="Info" variant="info" />

Sizes

3 9 42 128
<Badge value="3" size="xs" />
<Badge value="9" size="sm" />
<Badge value="42" size="md" />
<Badge value="128" size="lg" />

Dot mode

With dot, the badge collapses to an 8px circle — useful as an inline status indicator next to a label.

<Badge dot variant="success" />
<Badge dot variant="warning" />
<Badge dot variant="danger" />

API

PropTypeDefaultDescription
value string | number Text or count shown inside the badge. Ignored in dot mode.
variant 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info' 'primary' Background color intent.
size 'xs' | 'sm' | 'md' | 'lg' 'md' Badge height and text size.
dot boolean false Renders a small status dot with no text.

Accessibility

  • Purely presentational — pair with adjacent visible text so the count or status has a label.
  • Dot mode has no text content; convey its meaning through surrounding copy or an aria-label on the wrapper.
  • Color is not the only signal where possible — prefer text counts over color alone.

Theming surface

Every public token this component reads, extracted from its source at build time. The Resolves to column walks each token's real lineage — component → semantic → primitive → raw value — so you can see exactly where re-pointing it lands. A spoke re-skins by overriding these in its theme-<slug>.css; component internals are never edited. No hook for what you need? File it with /request-lego.

TokenTierResolves to
--badge-bg component #46a758 via --color-primary--color-grass-9
--badge-height-lg component 34px
--badge-height-md component 28px
--badge-height-sm component 22px
--badge-height-xs component 18px
--badge-radius component 0.25rem via --radius-100
--badge-text-color component #fcfcfc via --color-text-inverse--color-gray-1
--color-danger semantic #e5484d via --color-red-9
--color-danger-hover semantic #dc3e42 via --color-red-10
--color-info semantic #0090ff via --color-status-info--color-blue-9
--color-info-hover semantic #0588f0 via --color-blue-10
--color-primary-hover semantic #3e9b4f via --color-grass-10
--color-secondary semantic #65ba74 via --color-grass-8
--color-secondary-hover semantic #46a758 via --color-grass-9
--color-secondary-on-fill semantic #203c25 via --color-grass-12
--color-success semantic #bdee63 via --color-status-success--color-lime-9
--color-success-hover semantic #b0e64c via --color-lime-10
--color-success-on-fill semantic #37401c via --color-lime-12
--color-warning semantic #ffc53d via --color-status-warning--color-yellow-9
--color-warning-hover semantic #ffba18 via --color-yellow-10
--color-warning-on-fill semantic #4f3422 via --color-yellow-12
--radius-full primitive 9999px
--spacing-100 primitive 0.25rem
--spacing-150 primitive 0.375rem
--spacing-200 primitive 0.5rem
--spacing-300 primitive 0.75rem