Avatar group
Usage
Use the avatars prop to list the avatars, with the same name, image-url, icon, initials, color and variant as an Avatar. Use the label prop to name the group for screen readers.
<script setup lang="ts">
import type { AvatarGroupMember } from '@kuina-ui/vue'
const sharedWith: AvatarGroupMember[] = [
{ name: 'Avery Collins', imageUrl: '/avatars/avery-collins.webp' },
{ name: 'Jordan Reyes', imageUrl: '/avatars/jordan-reyes.webp' },
{ name: 'Riley Brooks', imageUrl: '/avatars/riley-brooks.webp' },
{ name: 'Kai Mensah', imageUrl: '/avatars/kai-mensah.webp' },
]
</script>
<template>
<KAvatarGroup :avatars="sharedWith" label="Shared with" />
</template>
Overflow count
Use the overflow-count prop to add an avatar at the end that shows how many more there are, like +5.
<KAvatarGroup :avatars="sharedWith" label="Shared with" :overflow-count="5" />
Stack
Use the stack prop to choose which avatar sits on top: the first one (start, default) or the last one (end).
<KAvatarGroup :avatars="sharedWith" label="Shared with" :overflow-count="5" />
<KAvatarGroup :avatars="sharedWith" label="Shared with" :overflow-count="5" stack="end" />
Size
Use the size prop to change the size of every avatar in the group, from 3xs to 6xl. The default is md. The overlap follows the size.
<KAvatarGroup :avatars="reviewers" label="Reviewers" size="sm" />
<KAvatarGroup :avatars="team" label="Team" size="3xl" :overflow-count="12" />
Surface
Each avatar has a ring that cuts it out from the one below. Use the surface prop to match the ring to the background behind the group: widget (default) for cards, or canvas for the page background.
<div class="bg-widget">
<KAvatarGroup :avatars="sharedWith" label="Shared with" />
</div>
<div class="bg-canvas">
<KAvatarGroup :avatars="sharedWith" label="Shared with" surface="canvas" />
</div>
Examples
With initials and icons
Mix images, initials and icons, each with its own color and variant.
<script setup lang="ts">
import type { AvatarGroupMember } from '@kuina-ui/vue'
import { Sparkles } from 'lucide-vue-next'
const budgetMembers: AvatarGroupMember[] = [
{ name: 'Avery Collins', initials: 'AC', color: 'info' },
{ name: 'Jordan Reyes', initials: 'JR', color: 'discovery' },
{ name: 'Riley Brooks', initials: 'RB', color: 'success' },
{ name: 'Assistant', icon: Sparkles, color: 'primary', variant: 'solid' },
]
</script>
<template>
<KAvatarGroup :avatars="budgetMembers" label="Budget members" size="xl" />
</template>
Customization
Use the ui prop to change the classes of the group, and class for the root element. Your classes always win: *:ring-1 replaces the default *:ring-3 instead of being added to it.
<KAvatarGroup :avatars="sharedWith" label="Shared with" :ui="{ base: '*:ring-1' }" />
API
Props
| Prop | Type | Default |
|---|---|---|
avatars | AvatarGroupMember[] | |
label | string | |
size | '3xs' | '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl' | 'md' |
stack | 'start' | 'end' | 'start' |
overflowCount | number | 0 |
surface | 'widget' | 'canvas' | 'widget' |
ui | { base? } | |
class | string |
AvatarGroupMember
| Property | Type |
|---|---|
name | string |
imageUrl | string |
icon | Component |
initials | string |
color | 'primary' | 'secondary' | 'gray' | 'success' | 'info' | 'discovery' | 'danger' |
variant | 'soft' | 'solid' |