# Avatar group

Who is here, as overlapping glass coins each cut out of the one behind it by a ring of the surface, ending in a grey +N.

Tier: free. Type: component. Category: data.

## Install

```bash
npx shadcn@latest add https://pixilui.com/r/avatar-group.json
```

One-time setup: add the registry to `components.json`:

```json
{
  "registries": {
    "@pixilui": "https://pixilui.com/r/{name}.json"
  }
}
```

Files: `components/pixilui/avatar-group.tsx`.

## Preview

Live preview: https://pixilui.com/components/avatar-group

Knobs:

- `size`: `32`, `24`, `40`

Signature: Each coin is cut out of the one behind it by a thin ring of the surface it sits on, so the stack reads cleanly on any card.

Styles: `lively` (default), `quiet`, set with `data-style` on <html>. The item reads the style through the foundation; it needs no prop. Standalone files: lively https://pixilui.com/r/standalone/avatar-group.tsx, quiet https://pixilui.com/r/standalone/avatar-group.quiet.tsx.

## Code

`components/pixilui/avatar-group.tsx`

```tsx
/*
  A stack of glass coins, locked 1 Dec 2026 with the user avatar (design/explorations/components/locked/user-avatar):
  each coin overlaps the one before by a fifth of a face and is cut out by a ring of the surface; the last can
  be +N, a grey coin. Its look is foundation.css section 8 (.pixilui-user-avatars). No motion of its own: a
  person arriving or leaving uses the foundation's arrive and leave (lib/motion/surface).
*/

import { forwardRef, type ComponentPropsWithoutRef, type ReactNode } from "react";
import { cn } from "./lib/utils";

export type AvatarGroupProps = ComponentPropsWithoutRef<"span"> & {
  /** The coins, as Avatar elements, first in front of the reading order. */
  children: ReactNode;
  /** How many more people there are: shown as a grey +N coin at the end. Zero or less shows nothing. */
  more?: number;
  /** The +N coin's accessible name, such as "3 more people". Without it the coin reads its number. */
  moreLabel?: string;
  /** The coins' size in px, for the +N coin; give the Avatars the same size. */
  size?: number;
};

/** Overlapping coins for who is here, each cut out of the one behind it, with an optional +N. */
export const AvatarGroup = forwardRef<HTMLSpanElement, AvatarGroupProps>(function AvatarGroup({ children, more, moreLabel, size, className, ...props }, ref) {
  return (
    <span ref={ref} className={cn("pixilui-user-avatars font-body", className)} {...props}>
      {children}
      {more && more > 0 ? <MoreCoin count={more} label={moreLabel} size={size} /> : null}
    </span>
  );
});

/** The +N coin: grey, for no one in particular. */
function MoreCoin({ count, label, size }: { count: number; label?: string; size?: number }) {
  const sized = size !== undefined && [16, 20, 24, 40, 48].includes(size) ? size : undefined;
  return (
    <span className="pixilui-user-avatar font-body" data-tone="grey" data-size={sized} {...(label ? { role: "img", "aria-label": label } : {})}>
      {`+${count}`}
    </span>
  );
}
```

## Usage

When to use:

- Who is watching a run, who is on a workspace, who approved.

When not to use:

- One person: use Avatar beside their name.
- A list people need to read: write the names.

```tsx
import { Avatar } from "@/components/pixilui/avatar";
import { Tooltip, TooltipGroup } from "@/components/pixilui/tooltip";
import { AvatarGroup } from "@/components/pixilui/avatar-group";

// The first option of each knob is the demo's default; the docs preview starts there.
export const knobs = {
  size: ["32", "24", "40"],
} as const;

const people: [string, string][] = [
  ["Maya Rao", "Admin"],
  ["Ben Ito", "Watching"],
  ["Hana Ito", "Editor"],
  ["Dev Patel", "Asked for this run"],
];

/** Who is on a run, with name tips that travel along the stack, and three more. */
export default function AvatarGroupDemo({ size = "32" }: KnobValues<typeof knobs>) {
  const px = Number(size);
  return (
    <div className="flex items-center gap-3 type-label text-secondary">
      <TooltipGroup>
        <AvatarGroup more={3} moreLabel="3 more people" size={px}>
          {people.map(([name, role]) => (
            <Tooltip key={name} label={name} secondary={role} name>
              <Avatar name={name} size={px} tabIndex={0} />
            </Tooltip>
          ))}
        </AvatarGroup>
      </TooltipGroup>
      <span>7 people on this run</span>
    </div>
  );
}
```

## Examples

None.

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` (required) | `ReactNode` |  | The coins, as Avatar elements, first in front of the reading order. |
| `more` | `number` |  | How many more people there are: shown as a grey +N coin at the end. Zero or less shows nothing. |
| `moreLabel` | `string` |  | The +N coin's accessible name, such as "3 more people". Without it the coin reads its number. |
| `size` | `number` |  | The coins' size in px, for the +N coin; give the Avatars the same size. |

Also accepts every native `<span>` attribute, and a ref to it.

## Keyboard

- `Tab`: Never takes focus on its own; wrap it in a TooltipGroup with name tips to make each coin a stop.

## Accessibility

- Each coin keeps its own name; the +N coin is named by moreLabel ("3 more people").
- For name tips that travel along the stack, give each coin a Tooltip with name inside a TooltipGroup.

## Motion

- None of its own: it holds still. A person arriving or leaving uses the foundation's arrive and leave.

## Responsive

- Each coin overlaps the one before by a fifth of a face; the stack keeps its size and never wraps.

## Performance

- Plain spans; the overlap and the cut-out ring are CSS in the foundation (section 8).

## Notes for AI

- <AvatarGroup more={3} moreLabel="3 more people"><Avatar name="Maya Chen" /><Avatar name="Ben Ito" /></AvatarGroup>.
- Give the Avatars and the group the same size; the +N coin takes the group's size.

## Related

- [Avatar](https://pixilui.com/components/avatar/markdown): A person as a coin of colored glass in their own color: initials, a figure, a photo or an empty seat, with a presence dot, its color picked from the name so a person looks the same everywhere.
- [Tooltip](https://pixilui.com/components/tooltip/markdown): One charcoal tooltip for every hover hint: a control's name and keys, why it can't act, a small breakdown, a person's name, cut-off text and long text, travelling with the pointer along a row.
