AvatarGroup
Stack of avatars representing a collection of users, with optional overflow tile and shared sizing.
Renders a <div> wrapper around child avatars; each Avatar retains its own name for screen readers. The overflow tile uses aria-label to announce hidden members.
import { Avatar, AvatarGroup } from '@arshad-shah/cynosure-react';
export default function Example() {
return (
<AvatarGroup>
<Avatar name="Jane Doe" />
<Avatar name="John Smith" />
<Avatar name="Ada Lovelace" />
</AvatarGroup>
);
}
With overflow
Section titled “With overflow”Use max to cap how many avatars render inline. Excess avatars collapse into a +N overflow tile that is automatically labelled for assistive tech.
import { Avatar, AvatarGroup } from '@arshad-shah/cynosure-react';
export default function Example() {
return (
<AvatarGroup max={3}>
<Avatar name="Jane Doe" />
<Avatar name="John Smith" />
<Avatar name="Ada Lovelace" />
<Avatar name="Grace Hopper" />
<Avatar name="Linus Torvalds" />
<Avatar name="Margaret Hamilton" />
</AvatarGroup>
);
}
The group’s size cascades to every child avatar (children may still override individually).
import { Avatar, AvatarGroup } from '@arshad-shah/cynosure-react';
export default function Example() {
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.75rem' }}>
<AvatarGroup size="sm">
<Avatar name="Jane Doe" />
<Avatar name="John Smith" />
<Avatar name="Ada Lovelace" />
</AvatarGroup>
<AvatarGroup size="md">
<Avatar name="Jane Doe" />
<Avatar name="John Smith" />
<Avatar name="Ada Lovelace" />
</AvatarGroup>
<AvatarGroup size="lg">
<Avatar name="Jane Doe" />
<Avatar name="John Smith" />
<Avatar name="Ada Lovelace" />
</AvatarGroup>
</div>
);
}
Ring and shape
Section titled “Ring and shape”ring is on by default to separate stacked avatars; pass ring={false} to disable. Use shape to switch between circle (default), rounded, and square tiles.
import { Avatar, AvatarGroup } from '@arshad-shah/cynosure-react';
export default function Example() {
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.75rem' }}>
<AvatarGroup shape="circle" max={4}>
<Avatar name="Jane Doe" />
<Avatar name="John Smith" />
<Avatar name="Ada Lovelace" />
<Avatar name="Grace Hopper" />
<Avatar name="Linus Torvalds" />
</AvatarGroup>
<AvatarGroup shape="rounded" max={4}>
<Avatar name="Jane Doe" shape="rounded" />
<Avatar name="John Smith" shape="rounded" />
<Avatar name="Ada Lovelace" shape="rounded" />
<Avatar name="Grace Hopper" shape="rounded" />
<Avatar name="Linus Torvalds" shape="rounded" />
</AvatarGroup>
<AvatarGroup ring={false} max={4}>
<Avatar name="Jane Doe" />
<Avatar name="John Smith" />
<Avatar name="Ada Lovelace" />
<Avatar name="Grace Hopper" />
<Avatar name="Linus Torvalds" />
</AvatarGroup>
</div>
);
}
Custom overflow
Section titled “Custom overflow”renderOverflow lets you swap the default +N tile for a fully custom node — useful for buttons that open a member list.
import { Avatar, AvatarGroup } from '@arshad-shah/cynosure-react';
export default function Example() {
return (
<AvatarGroup
max={2}
renderOverflow={(count) => (
<button
type="button"
aria-label={`Show ${count} more collaborators`}
style={{
all: 'unset',
cursor: 'pointer',
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
width: '2.5rem',
height: '2.5rem',
borderRadius: '9999px',
background: 'var(--cy-color-neutral-3, #eef0f4)',
color: 'var(--cy-color-neutral-12, #1a1f2c)',
fontSize: '0.8125rem',
fontWeight: 600,
}}
>
+{count}
</button>
)}
>
<Avatar name="Jane Doe" />
<Avatar name="John Smith" />
<Avatar name="Ada Lovelace" />
<Avatar name="Grace Hopper" />
<Avatar name="Linus Torvalds" />
</AvatarGroup>
);
}
Accessibility
Section titled “Accessibility”- Each child
Avatarshould carry anameso screen readers can announce membership individually. - The overflow tile sets
aria-label="{N} more"so assistive tech reports the hidden count. - Avoid stacking more than a handful of avatars without a
max— long stacks become noisy to navigate. - When the group represents a list, wrap it in a labelled landmark (
<section aria-label="Collaborators">).
Recipes
Section titled “Recipes”- Use
max={3}ormax={5}to keep dense rosters compact. - Pair each avatar with a
Tooltipso full names are accessible on hover and focus. - Pass
renderOverflow={(n) => <button>+{n}</button>}to make the overflow tile open a member dialog. - Set
ring={false}on backgrounds where the default ring colour blends in.