Avatar group
Several avatars overlapped into one cluster, with a plus-N count once they exceed the limit.
Purpose
An avatar group answers "who is involved?" at a glance — the reviewers on a claim, the members on
a corporate plan, the team behind a benefit group. It takes a flat list of people and does the
composition itself: overlap, initials fallback, and the "+N" chip once the list exceeds max.
For one person, use Avatar. Never overlap avatars by hand — the group owns the ring, spacing and overflow logic, so hand-rolled clusters drift the moment any of those change.
Example
Give it items — a name, and a src when a photo is on file. Initials are derived from the
name automatically (first letter of the first two words).
import { AvatarGroup } from "@healthmetrics/ui/avatar-group";
<AvatarGroup
items={[
{ name: "Aisyah Rahman", src: "/avatars/aisyah.jpg" },
{ name: "Lim Wei Jie" },
{ name: "Priya Nair" },
]}
/>Overflow
Beyond max (default 4), the rest collapse into a "+N" chip. Hovering the chip shows the hidden
names in a native tooltip.
size sets the avatar diameter in pixels when 32px is too small for the context:
Structure
The tokens behind the cluster.
| Property | Value |
|---|---|
| Diameter | 32px default, set per-group with size |
| Overlap | 8px (-ml-2) on every avatar after the first |
| Separation | 2px ring in --background, so overlaps stay legible on any fill |
| Initials | 12px (text-xs), first letters of the first two words, uppercased |
| Overflow chip | same diameter, --muted fill, 12px semibold --muted-foreground |
Best practices
Do
- Order
itemsby relevance — everything pastmaxdisappears into the chip. - Keep
maxmodest; a row of ten avatars is a list, not a glance. - Provide
srcwhen a photo exists — the initials fallback covers the rest automatically. - Pair the group with a full, readable list (a popover, a detail panel) wherever the complete membership actually matters.
Don't
- Compose overlapping Avatars by hand — the group exists so the ring, overlap and overflow stay consistent.
- Use it for organisations, clinics or documents — avatars signal people.
- Shrink
sizebelow 24px; two initials stop being legible. - Treat the chip as the only visible record of who is hidden — sighted keyboard and touch users never see its tooltip, even though screen readers hear the names.
Accessibility & keyboard
- Photos render with
altset to the person's name; the initials fallback is read as literal text, so every visible person is announced. - The "+N" chip announces the hidden names to screen readers ("+2: Kavitha Pillai, Daniel Ong")
via visually hidden text; the native
titletooltip remains as the pointer affordance. Sighted keyboard and touch users still cannot see the hidden names, so when the exact membership is load-bearing, present the full list somewhere persistent too. - The group renders a plain
<div>— no list semantics, no role. When the exact membership is load-bearing, present it as a real list nearby. - Keyboard: none — the group is non-interactive. If clicking it should open the full list, wrap it in a button that owns the focus and the name.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
itemsrequired | AvatarGroupItem[] | — | — |
max | number | undefined | 4 | Avatars shown before collapsing the rest into a “+N” count. |
size | number | undefined | 32 | Avatar diameter in pixels. |
Each entry in items:
| Prop | Type | Default | Description |
|---|---|---|---|
src | string | undefined | — | Image URL; initials fallback is used when absent or failing. |
namerequired | string | — | Full name — used for the tooltip title and initials fallback. |