# 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.

- Kind: Component (Layout)
- Docs: https://ui.minidev.pro/docs/avatar-group
- Source (registry JSON with the full file): https://ui.minidev.pro/r/avatar-group.json
- License: MIT. One file, yours to edit after install.

## 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`](https://ui.minidev.pro/docs/avatar) children by hand.

## Installation

### shadcn CLI (copies the source into your project)

```bash
npx shadcn@latest add @minidev/avatar-group
```

Writes `components/ui/avatar-group.tsx` plus the MiniDev files it is built from (popover, tooltip) and installs its npm dependencies. Older CLI versions: `npx shadcn@latest add https://ui.minidev.pro/r/avatar-group.json`.

### npm package

```bash
npm i minidev-ui-kit @base-ui/react
```

Add the tokens to your global stylesheet once:

```css
@import "tailwindcss";
@import "minidev-ui-kit/styles.css";
@source "../node_modules/minidev-ui-kit";
```

Next.js also needs `transpilePackages: ["minidev-ui-kit"]` in next.config.

## Import

After the shadcn install:

```tsx
import { AvatarGroup } from "@/components/ui/avatar-group"
```

From the npm package:

```tsx
import { AvatarGroup } from "minidev-ui-kit/ui/avatar-group"
```

## Usage

```tsx
import { AvatarGroup } from "@/components/ui/avatar-group"

export function Example() {
  return (
    <AvatarGroup />
  )
}
```

## Props

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `people` | `AvatarGroupPerson[]` | `TEAM` | no | Everyone in the group, in display order. Omit for sample data. |
| `max` | `number` | `5` | no | Avatars shown before the "+N" chip. If only one person would overflow, they are shown instead of "+1". |
| `size` | `"sm" \| "md" \| "lg"` | `"md"` | no | Avatar diameter: sm 24px, md 32px, lg 40px. |
| `label` | `string` | `"Northwind team"` | no | Accessible name for the group, also the overflow popover title. |
| `summary` | `boolean` | `true` | no | Show a "Maya, Theo and 7 others" line after the stack. |
| `className` | `string` | - | no |  |

## Examples

### Sizes

sm, md and lg; the overlap and the summary text scale with the avatars.

```tsx
<AvatarGroup size="sm" />
<AvatarGroup />
<AvatarGroup size="lg" />
```

### Custom people and max

Pass your own list; past max the rest collapse into a +N chip that opens a popover.

```tsx
<AvatarGroup
  label="Invoice approvers"
  max={3}
  people={[
    { name: "Maya Chen", role: "Head of Finance" },
    { name: "Theo Okafor", role: "Engineering lead" },
    { name: "Priya Raman", role: "Product designer" },
    { name: "Sam Lowe", role: "Controller" },
    { name: "Lucas Moreau", role: "Revenue ops" },
    { name: "Amara Nwosu", role: "Customer success" },
  ]}
/>
```

### Without summary

Turn the names line off for table cells and list rows where space is tight.

```tsx
<ul className="w-full max-w-sm divide-y divide-border rounded-xl border border-border bg-surface">
  <li className="flex items-center justify-between px-3 py-2.5">
    <span className="text-sm text-fg">Lumen billing</span>
    <AvatarGroup size="sm" summary={false} label="Billing" people={[{ name: "Maya Chen" }, { name: "Sam Lowe" }]} />
  </li>
  <li className="flex items-center justify-between px-3 py-2.5">
    <span className="text-sm text-fg">Northwind rollout</span>
    <AvatarGroup size="sm" summary={false} label="Rollout" people={[{ name: "Theo Okafor" }, { name: "Priya Raman" }, { name: "Kenji Sato" }]} />
  </li>
  <li className="flex items-center justify-between px-3 py-2.5">
    <span className="text-sm text-fg">Bank sync</span>
    <AvatarGroup size="sm" summary={false} label="Bank sync" people={[{ name: "Jonah Weiss" }]} />
  </li>
</ul>
```

## Keyboard interactions

| Key | Action |
| --- | --- |
| `Tab` | Moves to each avatar in turn, showing its name tooltip, then to the `+N` button. |
| `Enter` or `Space` | 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 an `aria-label` built from `label` and the count, for example "Northwind team, 9 people".
- Each avatar is `role="img"` named "Name, Role" (or just the name). The photo inside has `alt=""`, 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`.

## FAQ

### 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`](https://ui.minidev.pro/docs/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.

## Rules for generating code

- Use semantic tokens only (bg, surface, sunken, border, fg, fg-muted, fg-subtle, ink, accent, success, warning, danger). Never raw hex or palette steps like blue-500.
- Shadows only from the set: shadow-xs, shadow-sm, shadow-raised, shadow-md, shadow-lg, shadow-overlay.
- Numbers use tabular-nums. Dark mode is the `dark` class on <html>; components never branch on theme.

## Dependencies

- npm: `@base-ui/react`
- Built from: [popover](https://ui.minidev.pro/docs/popover/md), [tooltip](https://ui.minidev.pro/docs/tooltip/md)

## Related

- [Avatar](https://ui.minidev.pro/docs/avatar/md): Shadcn compatible avatar on Base UI with image and initials fallback, three sizes, a status badge and an overlapping avatar group with a plus count.
- [Live Cursors Bar](https://ui.minidev.pro/docs/live-cursors-bar/md): A multiplayer presence strip with overlapping colored avatars per collaborator and an editing now count. Suits docs, whiteboards and real time React editors.
- [User Chip](https://ui.minidev.pro/docs/user-chip/md): React user chip showing a small avatar with initials fallback and the person's name, plus an optional remove button. Good for assignees, mentions and pickers.
- [Animated Tooltip](https://ui.minidev.pro/docs/animated-tooltip/md): React row of overlapping avatars where hovering or focusing one pops up a name and role card that tilts and slides with the pointer on springs.
- [Accordion](https://ui.minidev.pro/docs/accordion/md): Accessible React accordion on Base UI, with bordered items, a rotating chevron and animated panels. Keyboard navigable, with one or many items open at once.
- [App Shell](https://ui.minidev.pro/docs/app-shell/md): Tailwind app shell layout with a fixed width sidebar slot, a topbar slot and a scrolling main area. The sidebar hides below the md breakpoint for mobile.

---

All 557 components: https://ui.minidev.pro/llms.txt (full text: https://ui.minidev.pro/llms-full.txt).
