# Avatar Group

An overlapping collection of avatars with an overflow summary.

An overlapping collection of avatars with an overflow summary.

```tsx
import { Avatar, AvatarGroup } from "@zentara-co/zenos-ui";

function AvatarGroupExample() {
  return (
    <AvatarGroup aria-label="Reviewers">
      <Avatar name="Alex Daniels" />
      <Avatar name="Mina Cho" />
      <Avatar name="Sam Ortiz" />
    </AvatarGroup>
  );
}
```

## Import

```tsx
import { AvatarGroup } from "@zentara-co/zenos-ui";
```

## Sizes

Set `size` once on the group. Every child Avatar and overflow control inherits it.

```tsx
import { Avatar, AvatarGroup, Stack } from "@zentara-co/zenos-ui";

function AvatarGroupSizesExample() {
  return (
    <Stack gap="4" align="start">
      {(["sm", "md", "lg"] as const).map((size) => (
        <AvatarGroup key={size} aria-label={`${size} reviewers`} size={size}>
          <Avatar name="Alex Daniels" />
          <Avatar name="Mina Cho" />
          <Avatar name="Sam Ortiz" />
        </AvatarGroup>
      ))}
    </Stack>
  );
}
```

## Shapes

The group also passes its shape to every child, keeping overlap and borders consistent.

```tsx
import { Avatar, AvatarGroup, Stack } from "@zentara-co/zenos-ui";

function AvatarGroupShapesExample() {
  return (
    <Stack direction="row" gap="6" align="center" wrap="wrap">
      {(["circle", "rounded", "square"] as const).map((shape) => (
        <AvatarGroup key={shape} aria-label={`${shape} reviewers`} shape={shape} size="lg">
          <Avatar name="Alex Daniels" />
          <Avatar name="Mina Cho" />
          <Avatar name="Sam Ortiz" />
        </AvatarGroup>
      ))}
    </Stack>
  );
}
```

## Overflow

Use `AvatarGroup.Overflow` to represent hidden members. Providing `onClick` makes it a keyboard-accessible button.

```tsx
import { Avatar, AvatarGroup, Stack, Text } from "@zentara-co/zenos-ui";
import { useState } from "react";

function AvatarGroupOverflowExample() {
  const [expanded, setExpanded] = useState(false);

  return (
    <Stack gap="3" align="start">
      <AvatarGroup aria-label="Project collaborators" size="lg">
        <Avatar name="Alex Daniels" />
        <Avatar name="Mina Cho" />
        <Avatar name="Sam Ortiz" />
        {!expanded && <AvatarGroup.Overflow count={8} onClick={() => setExpanded(true)} />}
        {expanded && (
          <>
            <Avatar name="Taylor Reed" />
            <Avatar name="Jordan Lee" />
          </>
        )}
      </AvatarGroup>
      <Text size="s" color="subtle">
        {expanded ? "Showing additional collaborators." : "Activate +8 to show more."}
      </Text>
    </Stack>
  );
}
```

## Group tooltip

Use a group tooltip when one summary describes the entire stack. Disable child tooltips to avoid competing hover targets.

```tsx
import { Avatar, AvatarGroup } from "@zentara-co/zenos-ui";

function AvatarGroupTooltipExample() {
  return (
    <AvatarGroup aria-label="Security reviewers" tooltip="Five security reviewers" size="lg">
      <Avatar name="Alex Daniels" tooltip={false} />
      <Avatar name="Mina Cho" tooltip={false} />
      <Avatar name="Sam Ortiz" tooltip={false} />
      <AvatarGroup.Overflow count={2} />
    </AvatarGroup>
  );
}
```

## Custom styling

Style the group surface with `className`, then use stable slots to coordinate child Avatar borders, fallbacks, and `AvatarGroup.Overflow`. Size, shape, overlap, accessible group naming, and roving focus behavior remain owned by the component.

```tsx
import { Avatar, AvatarGroup, Stack, Text } from "@zentara-co/zenos-ui";

function AvatarGroupCustomStylingExample() {
  return (
    <Stack
      direction="row"
      align="center"
      gap="4"
      className="w-full max-w-md rounded-xl border border-border-default bg-background-neutral-card p-4 shadow-raised"
    >
      <AvatarGroup
        aria-label="Campaign collaborators"
        size={60}
        className="shrink-0 [&_[data-slot=avatar-root]]:border-4 [&_[data-slot=avatar-root]]:border-background-neutral-card [&_[data-slot=avatar-root]]:shadow-raised"
      >
        <Avatar
          name="Alex Daniels"
          className="[&_[data-slot=avatar-fallback]]:bg-background-accent-purple-subtlest-pressed [&_[data-slot=avatar-fallback]]:text-text-accent-purple-bolder"
        />
        <Avatar
          name="Mina Cho"
          className="[&_[data-slot=avatar-fallback]]:bg-background-accent-teal-subtlest-pressed [&_[data-slot=avatar-fallback]]:text-text-accent-teal-bolder"
        />
        <Avatar
          name="Sam Ortiz"
          className="[&_[data-slot=avatar-fallback]]:bg-background-accent-orange-subtlest-pressed [&_[data-slot=avatar-fallback]]:text-text-accent-orange-bolder"
        />
        <AvatarGroup.Overflow
          count={5}
          className="border-4 border-background-neutral-card bg-background-accent-purple-bolder-default text-text-contrary before:bg-background-accent-purple-bolder-default"
        />
      </AvatarGroup>
      <Stack gap="0" className="min-w-0">
        <Text weight="medium">Campaign team</Text>
        <Text size="s" color="subtle">
          8 collaborators
        </Text>
      </Stack>
    </Stack>
  );
}
```

## Anatomy

```text
AvatarGroup.Root
AvatarGroup.Overflow
```

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| size | AvatarSize | md | Size inherited by child avatars. |
| shape | AvatarShape | circle | Shape inherited by child avatars. |
| tooltip | string | — | Optional tooltip describing the whole group. |
| count | number | — | Number of hidden avatars represented by AvatarGroup.Overflow. |
| native props | React.HTMLAttributes<HTMLDivElement> | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

## Accessibility

Give every group an accessible name. Interactive avatars and overflow controls use roving focus with Left, Right, Home, and End navigation. Keep every Avatar's `name` meaningful even when initials are visually sufficient.

Source: https://zenos-ui.pages.dev/components/avatar-group/