Passer au contenu principal

BadgeGroup

Implemented

Cluster of removable label badges with overflow handling. Renders its own label chips — does not compose the Badge atom.

Categorymolecules
Sourcepatterns/molecules/badgegroup.html
AI HintUse for grouped UI patterns. Combine atoms into functional units.

Cluster of removable label badges with overflow handling. Renders its own label chips — it does not compose the Badge atom.

BadgeGroup

Display molecule (Family 4 — Tier 1)

Renders a group of label badges with a `+N` overflow indicator. Each badge is a `{ id, label, variant?, onRemove?, onClick? }` item; badges with an `onRemove` get an X button. Renders `emptyMessage` when the list is empty.

NewHotLow stock
SalePresaleVIP+2View detail

This component supports light and dark mode.

Usage

BadgeGroup renders its own label chips (its own variant vocabulary: default/primary/success/warning/error/info) — it does NOT compose the Badge atom. For numeric counts use Badge.

import { BadgeGroup } from '@epasslive/design-system'

<BadgeGroup
  badges={[
    { id: 'new', label: 'New', variant: 'primary' },
    { id: 'hot', label: 'Hot', variant: 'error' },
    { id: 'sale', label: 'Sale', onRemove: () => removeFilter('sale') },
  ]}
  ariaLabel="Active product filters"
  maxVisible={3}
/>

Props

Prop
Type
Default
Description
badges*
Badge[]
—

Badge items: `{ id: string; label: string; variant?: 'default' | 'primary' | 'success' | 'warning' | 'error' | 'info'; onRemove?: () => void; onClick?: () => void }`.

maxVisible
number
3

Maximum visible badges; the rest collapse into a `+N` indicator.

variant
'default' | 'compact'
default

Display variant. `compact` hides remove buttons until hover.

ariaLabel*
string
—

Accessible name for the group (`role="group"`).

emptyMessage
string
—

Message rendered when `badges` is empty.

trailing
React.ReactNode
—

Content rendered after the badge row — e.g. a View-detail TextLink — inside the group semantics.

className
string
—

Additional CSS classes on the group container.

id
string
—

Root element id (falls back to a generated `useId`).

Props

Preview

BadgeGroup

Prop
Type
Required
Default
Description
badges
Badge[]
Required
—

Badge items to display

maxVisible
number
Optional
3

Maximum visible badges

variant
'default' | 'compact'
Optional
'default'

Display variant. 'compact' hides remove buttons until hover.

ariaLabel
string
Required
—

Accessible name for the group (role='group').

emptyMessage
string
Optional
—

Message rendered when badges is empty.

trailing
React.ReactNode
Optional
—

Content rendered after the badge row (§126 Wave 3 #7) — e.g. a View-detail TextLink — inside the group semantics.

className
string
Optional
—

Additional CSS classes on the group container.

id
string
Optional
—

Root element id (falls back to a generated useId).

Quick use:<BadgeGroup />

Accessibility

ARIA rolegroup

ARIA

1 rule

WCAG 1.3.1

Group container exposes role='group' with the caller-supplied ariaLabel (the count itself is not announced)

validation

1 rule

NASA Rule 5

Badges beyond maxVisible collapse to a '+N' chip announcing '{N} more badges' (99+ cap not yet implemented)

Usage

Import

tsxSnippet
import { BadgeGroup } from "@epasslive/design-system"

Example 1

tsxSnippet
<BadgeGroup badges={[{ id: 'new', label: 'New', variant: 'primary' }, { id: 'hot', label: 'Hot', variant: 'error' }]} ariaLabel='Active filters' />

Example 2

tsxSnippet
<BadgeGroup badges={[{ id: 'sale', label: 'Sale', onRemove: () => removeFilter('sale') }]} ariaLabel='Selected filters' />

Anti-patterns

— Do not hardcode data in molecules

— Avoid complex business logic in molecules

Design System v4.1.0 | ePassLive