# Avatar Group

## Usage

Import the components from their dedicated entry. Structural styles are loaded automatically.

```vue
<script setup lang="ts">
import { Avatar, AvatarGroup, AvatarGroupOverflow } from '@astryx-vue/core/AvatarGroup'
</script>

<template>
  <AvatarGroup size="md">
    <Avatar name="Ana Thomas" />
    <Avatar name="Ben Lee" />
    <Avatar name="Carol Davis" />
    <AvatarGroupOverflow :count="5" />
  </AvatarGroup>
</template>
```

### Anatomy

- **Avatars**: Avatar elements that form the overlapping row. Each can have its own props.
- **Overflow indicator**: A "+N" circle at the end showing hidden count, or a custom AvatarGroupOverflow slot.

## Best practices

| Guidance | Practice |
| --- | --- |
| Recommended | Set `size` and `shape` on `AvatarGroup` so child avatars inherit them. |
| Recommended | Pass only the avatars you want to show, and use `AvatarGroupOverflow` for the rest. |
| Recommended | When there are many avatars, show the most recently active or important users first. |
| Don't | Set different `size` or `shape` on individual avatars inside a group. |
| Don't | Show too many avatars. Typically show 3–5 and summarize the rest with the overflow counter. |

## Examples

### Group

Overlap multiple avatars in a row to represent a group of people. Use for team lists, PR reviewers, or participant counts where you want to show faces without taking up much space.

```vue
<script setup lang="ts">
import { Avatar } from '@astryx-vue/core/Avatar'
import { AvatarGroup, AvatarGroupOverflow } from '@astryx-vue/core/AvatarGroup'
import { Stack } from '@astryx-vue/core/Stack'
import { Text } from '@astryx-vue/core/Text'

const users = [
  { name: 'Ami Pena', src: '/template-assets/DATA-Ami-Pena.png' },
  { name: 'Drew Young', src: '/template-assets/DATA-Drew-Young.png' },
  { name: 'Gabriela Fernandez', src: '/template-assets/DATA-Gabriela-Fernandez.png' },
  { name: 'Jihoo Song', src: '/template-assets/DATA-Jihoo-Song.png' },
  { name: 'Nam Tran', src: '/template-assets/DATA-Nam-Tran.png' },
]
</script>

<template>
  <Stack direction="vertical" :gap="8">
    <Stack direction="vertical" :gap="3">
      <Text type="supporting" color="secondary">
        Team members
      </Text>
      <AvatarGroup size="lg">
        <Avatar v-for="user in users" :key="user.name" :src="user.src" :name="user.name" />
        <AvatarGroupOverflow :count="3" />
      </AvatarGroup>
    </Stack>
    <Stack direction="vertical" :gap="3">
      <Text type="supporting" color="secondary">
        Larger group
      </Text>
      <AvatarGroup size="lg">
        <Avatar v-for="user in users.slice(0, 3)" :key="user.name" :src="user.src" :name="user.name" />
        <AvatarGroupOverflow :count="8" />
      </AvatarGroup>
    </Stack>
  </Stack>
</template>
```

### Interactive

A facepile whose avatars link to profiles, with an overflow indicator that opens the full member list. The whole group is one Tab stop; arrow keys move between the avatars and the overflow button.

```vue
<script setup lang="ts">
import { Avatar } from '@astryx-vue/core/Avatar'
import { AvatarGroup, AvatarGroupOverflow } from '@astryx-vue/core/AvatarGroup'
import { Stack } from '@astryx-vue/core/Stack'
import { Text } from '@astryx-vue/core/Text'

const members = [
  { name: 'Alex Daniels', key: 'alex', href: '/team/alex' },
  { name: 'Ann Smith', key: 'ann', href: '/team/ann' },
  { name: 'Carol Davis', key: 'carol', href: '/team/carol' },
]
const totalMembers = 18
</script>

<template>
  <Stack direction="vertical" :gap="8">
    <Stack direction="vertical" :gap="3">
      <Text type="supporting" color="secondary">
        Reviewers
      </Text>
      <AvatarGroup size="lg" label="Reviewers">
        <Avatar v-for="member in members" :key="member.key" :name="member.name" :href="member.href" />
        <AvatarGroupOverflow :count="totalMembers - members.length" @click="() => {}" />
      </AvatarGroup>
    </Stack>
    <Stack direction="vertical" :gap="3">
      <Text type="supporting" color="secondary">
        Compact, static
      </Text>
      <AvatarGroup size="sm" label="Attendees">
        <Avatar v-for="member in members" :key="member.key" :name="member.name" />
        <AvatarGroupOverflow :count="totalMembers - members.length" />
      </AvatarGroup>
    </Stack>
  </Stack>
</template>
```

## AvatarGroup Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `AvatarSize` | `'md'` | Uniform size for all avatars in the group: a named size or one of the numeric pixel values `AvatarSize` lists. It always overrides each child Avatar's own size, including when the group uses its default. |
| `shape` | `AvatarShape` | `'circle'` | Uniform shape for all avatars in the group. |

## AvatarGroupOverflow Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `count` | `number` | - | Number of hidden avatars, displayed as +N. |

| Name | Description |
| --- | --- |
| `click` | Fired when the indicator is clicked. With a listener the indicator becomes a focusable button instead of a static figure. |

The <code>default</code> slot replaces the <code>+N</code> text, for wordings such as <code>12+</code>.

## Slots

| Name | Description |
| --- | --- |
| `default` | `Avatar` elements, optionally ending with an `AvatarGroupOverflow`. |

## Native attributes

The root element is a `<div role="group">`.

The following are passed to the root element:

- HTML attributes.
- `aria-*` attributes.
- `data-*` attributes.
- `class`.
- `style`.
