icon

Morainev0.5.0

AvatarGroup
elementsavatar-group

AvatarGroup

Group of overlapping avatars with an optional overflow count.

Import#

import { AvatarGroup } from 'moraine'

Usage#

AvatarGroup renders multiple Avatar items as an overlapping group with an optional overflow count. Use Avatar for a standalone avatar.

Slot Structure#

root
├── count (optional, overflow count)
└── item (×n)
├── image
├── fallback
│ └── fallbackIcon (Icon, optional)
└── badge (optional)

Examples#

Basic#

function Basic() {
return <AvatarGroup items={[{ text: 'A' }, { text: 'B' }, { text: 'C' }]} />
}

Overflow Count#

function Overflow() {
return (
<AvatarGroup
max={3}
items={[
{ text: 'AL' },
{ text: 'BM' },
{ text: 'CN', badge: 'i-lucide-check', badgePosition: 'top-right' },
{ text: 'DO' },
{ text: 'EP' },
]}
/>
)
}

Sizes#

function Sizes() {
const SIZES: AvatarGroupSize[] = ['xs', 'sm', 'md', 'lg', 'xl']
return (
<div class="flex flex-wrap gap-4 items-end">
<For each={SIZES}>
{(size) => (
<div class="flex flex-col gap-2 items-center">
<AvatarGroup
size={size}
max={2}
items={[{ text: 'A' }, { text: 'B' }, { text: 'C' }]}
/>
<span class="text-xs text-muted-foreground font-mono">{size}</span>
</div>
)}
</For>
</div>
)
}

API Reference#

Attributes#

Slotroot0 attributes
Container of grouped avatars.
No attribute metadata for this slot.

Props#

PropTypeDefaultDescription
classClassValue
Class applied to the component root or trigger element.
classesAvatarGroupT.Classes | undefined
itemsAvatarGroupT.Item[] | undefined[]
Array of avatars to render in the group.
maxstring | number | undefined
Maximum number of avatars to show.
refJSX.HTMLElementTags["div"] extends { ref?: infer Ref; } ? Ref : never | undefined
size"xs" | "sm" | "md" | "lg" | "xl" | undefined
styleJSX.CSSProperties | undefined
stylesAvatarGroupT.Styles | undefined
transition"none" | "fast" | "normal" | "slow" | undefined

Items#

PropTypeDefaultDescription
altstring | undefined
Accessible alt text for the avatar.
badgeIconT.Name
Icon name for the badge.
badgePositionNonNullable<"top-left" | "top-right" | "bottom-left" | "bottom-right" | undefined> | undefinedbottom-right
Position of the badge.
fallbackIconT.Name
Icon name to show as fallback.
onStatusChange((status: AvatarStatus) => void) | undefined
Callback when the loading status of the avatar changes.
srcstring | undefined
Source URL for the avatar image.
textstring | undefined
Initial text to show if image fails or is missing.