Avatar Group
Stack of avatars with overflow count badge.
<arc-avatar-group>Overview
AvatarGroup overlaps a row of arc-avatar elements and shows a "+N" count when there are more than max. Avatars past max get display: none, and earlier avatars stack on top of later ones.
The overlap alone would work as plain CSS. Hiding the extra avatars and counting them is script, and that script also runs during server rendering, so the count is there on first paint.
Guidelines
Do
- Set max to 3 to 5 to keep the group compact
- Use the same avatar size throughout a group so the overlap lines up
- Use md overlap in most places, sm in tight spaces and lg with larger avatars
- Use it for team members, comment threads and who-is-here indicators
Don't
- Don't slot anything but arc-avatar. The margin and z-index logic assumes avatars
- Don't use it for one avatar. It only adds wrapper markup
Features
- `overlap` presets: sm (-8px), md (-12px), lg (-16px), applied as a negative left margin on every avatar but the first
- The "+N" count is text in the label font, after the last visible avatar
- The wrapper has `role="group"` and `aria-label="Avatar group"`
Preview
A
B
C
Usage
<arc-avatar-group max="3">
<arc-avatar name="Alice"></arc-avatar>
<arc-avatar name="Bob"></arc-avatar>
<arc-avatar name="Charlie"></arc-avatar>
<arc-avatar name="Diana"></arc-avatar>
</arc-avatar-group>import { Avatar, AvatarGroup } from '@arclux/arc-ui-react';
export default function Example() {
return (
<AvatarGroup max="3">
<Avatar name="Alice" />
<Avatar name="Bob" />
<Avatar name="Charlie" />
<Avatar name="Diana" />
</AvatarGroup>
);
}<script setup>
import { Avatar, AvatarGroup } from '@arclux/arc-ui-vue';
</script>
<template>
<AvatarGroup max="3">
<Avatar name="Alice" />
<Avatar name="Bob" />
<Avatar name="Charlie" />
<Avatar name="Diana" />
</AvatarGroup>
</template><script>
import { Avatar, AvatarGroup } from '@arclux/arc-ui-svelte';
</script>
<AvatarGroup max="3">
<Avatar name="Alice" />
<Avatar name="Bob" />
<Avatar name="Charlie" />
<Avatar name="Diana" />
</AvatarGroup>import { Component } from '@angular/core';
import { Avatar, AvatarGroup } from '@arclux/arc-ui-angular';
@Component({
imports: [Avatar, AvatarGroup],
template: `
<arc-avatar-group max="3">
<arc-avatar name="Alice"></arc-avatar>
<arc-avatar name="Bob"></arc-avatar>
<arc-avatar name="Charlie"></arc-avatar>
<arc-avatar name="Diana"></arc-avatar>
</arc-avatar-group>
`,
})
export class MyComponent {}import { Avatar, AvatarGroup } from '@arclux/arc-ui-solid';
export default function Example() {
return (
<AvatarGroup max="3">
<Avatar name="Alice" />
<Avatar name="Bob" />
<Avatar name="Charlie" />
<Avatar name="Diana" />
</AvatarGroup>
);
}import { Avatar, AvatarGroup } from '@arclux/arc-ui-preact';
export default function Example() {
return (
<AvatarGroup max="3">
<Avatar name="Alice" />
<Avatar name="Bob" />
<Avatar name="Charlie" />
<Avatar name="Diana" />
</AvatarGroup>
);
}<!-- Auto-generated by @arclux/prism — do not edit manually -->
<!-- arc-avatar-group — requires avatar-group.css + base.css (or arc-ui.css) -->
<span class="arc-avatar-group">
<div class="group" role="group" aria-label="Avatar group">
AvatarGroup
<span class="group__overflow" style="display:none"></span>
</div>
</span><!-- Auto-generated by @arclux/prism — do not edit manually -->
<!-- arc-avatar-group — self-contained, no external CSS needed -->
<span class="arc-avatar-group" style="display: inline-flex">
<div style="display: flex; align-items: center" role="group" aria-label="Avatar group">
AvatarGroup
<span style="display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 9999px; background: rgb(17, 17, 22); border: 1px solid rgb(34, 34, 41); font-family: 'Tomorrow', system-ui, sans-serif; font-weight: 600; font-size: 12px; color: rgb(124, 124, 137); user-select: none" style="display:none"></span>
</div>
</span>API
maxnumberInfinity- Maximum number of avatars to display. Excess avatars are hidden and a "+N" overflow badge is shown.
overlap'sm' | 'md' | 'lg''md'- Overlap density preset. sm = -8px, md = -12px, lg = -16px negative margin between avatars.