# AvatarGroup

> Overlapping stack of Avatars with a +N overflow bubble.

- Status: beta
- Group: display
- Page: https://www.digitaltableteur.com/design-system/components/avatar-group
- Contract: https://www.digitaltableteur.com/contracts/v1/AvatarGroup.contract.json

## When to use

AvatarGroup answers "who is on this?" at a glance: the first max Avatars overlap into a stack and the remainder collapses into a +N bubble that also announces itself to screen readers. Pass same-size Avatars and set the matching group size (sm=2rem, md=2.5rem, lg=3rem) so the bubble lines up.

## When not to use

- Do not use the +N bubble as a button; if the full roster matters, link to it separately.

## Look-alikes

The contract names no look-alike with a deciding condition.

## Props

| Prop | Type | Default | Description | Required |
| --- | --- | --- | --- | --- |
| `ariaLabel` | `string` | none | Accessible name for the cluster (e.g. "Project members"). | No |
| `max` | `number` | `4` | Avatars beyond this count collapse into a "+N" bubble. | No |
| `size` | `"sm" \| "md" \| "lg"` | `md` | Size of the overflow bubble; children Avatars should match (sm=2rem, md=2.5rem, lg=3rem). | No |
| `children` | `React.ReactNode` | none | No description in the contract. | Yes |

## Variants

- Available sizes: `sm`, `md`, `lg` (default `md`).

## Invalid combinations

The contract records no invalid combinations.

## Keyboard

| Key | Behaviour |
| --- | --- |
| Tab | Reaches clickable Avatars only; static stacks have no stops. |

## Rules

Every item under When not to use is a MUST NOT. MUST and SHOULD follow RFC 2119.

| Level | Rule | How it is checked |
| --- | --- | --- |
| MUST | ARIA: Role=group with aria-label naming the cluster. | Not yet verified: no evidence record. WCAG 4.1.2. |
| MUST | ARIA: Overflow bubble announces 'N more' via sr-only text. | Not yet verified: no evidence record. WCAG 4.1.2. |
| MUST | Required stories produce no axe violations at the configured severity. | Automated by `npm run test:stories:matrix:ci`. WCAG 2.5.8. |
| MUST | The accessibility tree (role, name, state) matches the committed snapshot for every required story. | Automated by `npm run test:stories:matrix:ci`. WCAG 1.3.1, 4.1.2. |
| MUST | The component remains legible and operable under a real browser forced-colors: active pass. | Automated by `npm run test:stories:hc`. |
| MUST | Every documented keyboard interaction works as specified. | Not yet verified: no evidence record. WCAG 2.1.1, 2.1.2. |
| MUST | A human completed an end-to-end accessibility review of this component. | Manual review, last on 2026-07-03. |
| SHOULD | Keep max between 3 and 5; past that the stack stops being scannable and the +N carries the message. | Not stated in the contract. |
| SHOULD | Match children Avatar sizes to the group size so the overflow bubble aligns with the faces. | Not stated in the contract. |
| SHOULD | Name the cluster with ariaLabel ("Project members"); the group role reads it before the names. | Not stated in the contract. |
| SHOULD | Order children by relevance; the first faces are the ones people see. | Not stated in the contract. |
| SHOULD NOT | Do not mix Avatar sizes in one stack; the overlap rhythm breaks. | Not stated in the contract. |

## Install and import

- Install: `npm install @digitaltableteur/react` (version 0.9.1, restricted access on npm).
- Import: `import { AvatarGroup } from "@digitaltableteur/react";`
- Entry point: `@digitaltableteur/react/identity` exports it too.
- Styles: import `@digitaltableteur/react/style.css` once at the app boundary.
- Also available as the custom element `<dt-avatar-group>`; see the custom elements manifest.

## Links

- Machine-readable contract (Design System Contract 1.0): https://www.digitaltableteur.com/contracts/v1/AvatarGroup.contract.json
- Markdown version of this page: https://www.digitaltableteur.com/design-system/components/avatar-group.md
- Component index as JSON: https://www.digitaltableteur.com/design-system/components.json
- All components: https://www.digitaltableteur.com/design-system/components
- Source: The implementation lives in a private repository. This page, its Markdown twin and the contract are generated from it at build time and are the public source of truth.
