AvatarGroup
Import
Section titled “Import”import { AvatarGroup } from '@delightstack/components';Basic Usage
Section titled “Basic Usage” A
B
C
View code
<script> import { AvatarGroup } from '@delightstack/components';
const members = [ { name: 'Alice', src: '/avatars/alice.jpg' }, { name: 'Bob', src: '/avatars/bob.jpg' }, { name: 'Charlie', src: '/avatars/charlie.jpg' }, ];</script>
<AvatarGroup avatars={members} />Examples
Section titled “Examples”Limiting Visible Avatars
Section titled “Limiting Visible Avatars”When the number of avatars exceeds max, a “+N” overflow indicator appears.
<script> const team = [ { name: 'Alice', src: '/avatars/alice.jpg' }, { name: 'Bob', src: '/avatars/bob.jpg' }, { name: 'Charlie', src: '/avatars/charlie.jpg' }, { name: 'Diana', src: '/avatars/diana.jpg' }, { name: 'Eve', src: '/avatars/eve.jpg' }, { name: 'Frank', src: '/avatars/frank.jpg' }, ];</script>
<AvatarGroup avatars={team} max={3} />Different Sizes
Section titled “Different Sizes” A
B
C
D
A
B
C
D
A
B
C
D
View code
<AvatarGroup avatars={team} size="0" max={4} /><AvatarGroup avatars={team} size="2" max={4} /><AvatarGroup avatars={team} size="3" max={4} />Expandable Overflow
Section titled “Expandable Overflow”When expandable is true, clicking the overflow indicator reveals all hidden avatars.
AJ
BS
CB
+3
View code
<AvatarGroupavatars={team}max={3}expandable/>Clickable Avatars
Section titled “Clickable Avatars” AJ
BS
CB
DP
View code
<AvatarGroupavatars={team}onclick={({ avatar, index }) => openProfile(avatar)}/>With Overflow Click Handler
Section titled “With Overflow Click Handler” AJ
BS
CB
+3
View code
<AvatarGroupavatars={team}max={3}onoverflowclick={({ remaining }) => showAllParticipants(remaining)}/>Skeleton Loading
Section titled “Skeleton Loading”View code
<AvatarGroup skeleton={loading} skeleton_count={4} avatars={loading ? [] : members} />| Prop | Type | Default | Description |
|---|---|---|---|
avatars | AvatarData[] | [] | Array of avatar data |
max | number | 5 | Maximum visible avatars before overflow |
size | '0' | '1' | '2' | '3' | '4' | '5' | '1' | Avatar size (passed to each Avatar) |
overlap | number | 0.25 | Overlap ratio (0-1) |
direction | 'left' | 'right' | 'right' | Stack direction |
ring_color | string | 'var(--color-bg)' | Ring/border color around each avatar |
expandable | boolean | false | Click overflow to reveal all |
skeleton | boolean | false | Show loading skeleton |
skeleton_count | number | 4 | Number of skeleton circles to show |
id | string | auto | Element ID |
class | string | '' | Additional CSS classes |
Events
Section titled “Events”| Event | Detail | Description |
|---|---|---|
onclick | { avatar: AvatarData, index: number } | Individual avatar clicked |
onoverflowclick | { remaining: AvatarData[] } | Overflow “+N” indicator clicked |
interface AvatarData { src?: string; name: string; href?: string;}Accessibility
Section titled “Accessibility”- Container has
role="group"witharia-label="Avatar group" - Each avatar has an accessible name from the
namefield inAvatarData - Tooltips display each avatar’s name on hover
- Overflow indicator has
aria-label(e.g., “3 more avatars”) - When
expandableoronoverflowclickis set, the overflow indicator hasrole="button"and is keyboard accessible (Enter/Space) - Hovered avatar rises slightly with
translateY(-2px)for visual feedback