Avatar Group
React avatar group that stacks overlapping avatars with tooltips, collapses extras into a +N chip with a popover list and falls back to tinted initials.
Installation
npx shadcn@latest add @minidev/avatar-group
MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/avatar-group.json
Usage
import { AvatarGroup } from "@/components/ui/avatar-group"
export function Example() {
return (
<AvatarGroup />
)
}
API reference
| Prop | Type | Default |
|---|---|---|
| peopleEveryone in the group, in display order. Omit for sample data. | AvatarGroupPerson[] | TEAM |
| maxAvatars shown before the "+N" chip. If only one person would overflow, they are shown instead of "+1". | number | 5 |
| sizeAvatar diameter: sm 24px, md 32px, lg 40px. | "sm""md""lg" | "md" |
| labelAccessible name for the group, also the overflow popover title. | string | "Northwind team" |
| summaryShow a "Maya, Theo and 7 others" line after the stack. | boolean | true |
| className | string | - |
When to use
Each avatar is ringed in the surface colour so the stack reads cleanly on cards; hovering or focusing one lifts it above its neighbours without moving the layout. Initials on token-tinted backgrounds stand in for missing photos. Data-driven: pass people. Prefer the AvatarGroup exported from avatar (a plain flex wrapper) when you compose Avatar children by hand.
Keyboard interactions
| Key | Action |
|---|---|
| Tab | Moves to each avatar in turn, showing its name tooltip, then to the +N button. |
| EnterorSpace | On the +N button, opens the list of everyone not shown. |
| Escape | Closes the tooltip or the overflow list. Closing the list returns focus to the +N button. |
Accessibility
- The stack is
role="group"with anaria-labelbuilt fromlabeland the count, for example "Northwind team, 9 people". - Each avatar is
role="img"named "Name, Role" (or just the name). The photo inside hasalt="", so the name is not read twice. - The overflow button is labelled "Show 2 more", and the popover opens with the line "2 more on Northwind team".
- The lift on hover and focus is a 140ms transform. The kit's stylesheet cuts it to 0.01ms under
prefers-reduced-motion: reduce.
Frequently asked questions
What is the difference between this AvatarGroup and the one in Avatar?
This one is data-driven: pass people and it draws the stack, a name tooltip on each avatar, the +N popover and the summary line. The AvatarGroup exported from Avatar is a plain flex wrapper for Avatar children you compose yourself. Both have the same name, so rename one on import if a file needs both.
Why does max={4} show five avatars?
It never hides a single person behind +1. With 5 people and max={4} all five show; with 6 people you get four avatars and +2.
How do I change or hide the "Maya, Theo and 7 others" line?
Pass summary={false} to hide it. The line uses the first word of the first two names and the count of everyone else, and reads "No one yet" for an empty people array. For other wording, hide it and write your own next to the group.
What shows while a photo loads or if it fails?
Initials from the first and last word of name, on a tint picked from a hash of the name. The same person always gets the same colour, in both themes.
Dependencies
Examples
Sizes
sm, md and lg; the overlap and the summary text scale with the avatars.
Custom people and max
Pass your own list; past max the rest collapse into a +N chip that opens a popover.
Without summary
Turn the names line off for table cells and list rows where space is tight.