Avatar Group
Show several people as a row of overlapping avatars with an optional overflow count.
Installation
pnpm dlx shadcn@4.18.0 add @siteplane/avatar-groupComplete the one-time setup first. Registry JSON lists source files and dependencies.
For this page’s examples, also install:
pnpm dlx shadcn@4.18.0 add @siteplane/avatar @siteplane/cardUsage
import {
Avatar,
AvatarFallback,
AvatarImage,
} from "@/siteplane/components/avatar";
import {
AvatarGroup,
AvatarGroupCount,
} from "@/siteplane/components/avatar-group";
<AvatarGroup>
<Avatar>
<AvatarImage src="/avatars/mara-ellis.png" alt="Mara Ellis" />
<AvatarFallback>ME</AvatarFallback>
</Avatar>
<Avatar>
<AvatarImage src="/avatars/ben-carter.png" alt="Ben Carter" />
<AvatarFallback>BC</AvatarFallback>
</Avatar>
<AvatarGroupCount>
+2<span className="sr-only"> more members</span>
</AvatarGroupCount>
</AvatarGroup>;Composition
AvatarGroup
├── Avatar (one per person)
└── AvatarGroupCount (optional)Put the avatars directly in the group, followed by an AvatarGroupCount for the people it does not show. Each item after the first overlaps the one before it by a quarter of its size, and later items sit on top of earlier ones. Every avatar and the count draw a 2 px ring in the color of the surface they sit on, so the circles stay apart on the page, on a Card or in a Dialog.
Sizes
Set size on the group, not on each avatar: sm 24 px, md 32 px (the default, the size of a single Avatar), lg 40 px or xl 48 px. The group sizes every avatar and the count, and the overlap scales with the size.
Large counts
Pass the number of people the group does not show as count. The count writes it as +12, and from 1,000 on in compact notation, such as +1.3K, with the exact number as its title; assistive technology reads the exact number, followed by the children, such as visually hidden text that says what it counts. A count never truncates: a longer one grows as a pill of the group's height, and a short one stays a circle. locale sets the locale that writes the number, en-US unless set, so the server and the browser render the same text.
On a card
The ring takes the color of the Card, so the group needs no border of its own. A small group fits in the CardAction beside a title, for example the reviewers of a task.
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
Avatar | sm | md | lg | xl | md | Size of every avatar and the count: 24, 32, 40 or 48 px. The overlap is a quarter of it. |
Avatar | ReactElement | render function | div | Composes the group onto another element. |
Avatar | string | unset | Classes for the row. |
Avatar | number | unset | The number of people the group does not show, written as +N and from 1,000 on in compact notation (+1.3K), with the exact number for assistive technology and as the title. |
Avatar | string | en-US | The locale that writes count. |
Avatar | ReactNode | unset | The count as text, such as +2, or the words after count; give the count an accessible name that says what it counts. |
Avatar | ReactElement | render function | span | Composes the count onto another element, such as a link to the full list. |
AvatarGroup renders a div with data-slot="avatar-group" and accepts native div props and refs. AvatarGroupCount renders a span with data-slot="avatar-group-count" and accepts the props of Badge except variant, size, shape, profile and light, which the group sets. With count, the visible figure is a span with data-slot="avatar-group-count-value". The module exports AvatarGroupProps, AvatarGroupSize and AvatarGroupCountProps.
Usage notes
The application decides how many avatars to show and what the count says. Give each avatar a name: an image needs a meaningful alt, and an avatar that shows only initials can take role="img" and an aria-label. Give the count an accessible name that says what it counts, such as visually hidden text after the number.