vael-ui v0.5.7

Data display

Layout

AvatarGroup

Several avatars stacked into one overlapping row, with a count for the ones that don’t fit. Use it to show who belongs to a team, a chat or a document.

Install

import { AvatarGroup } from 'vael-ui'

Playground

ALGHKJ
Usage
<script setup lang="ts">
import { AvatarGroup, Avatar } from 'vael-ui'
</script>

<template>
  <AvatarGroup>
    <Avatar name="Ada Lovelace" />
    <Avatar name="Grace Hopper" />
    <Avatar name="Katherine Johnson" />
  </AvatarGroup>
</template>

Props

NameTypeDefaultDescription
size'sm' | 'md' | 'lg''md'Sizes the generated overflow avatar; slotted Avatars keep their own size prop.
overflowCountnumber0Number of items you didn't render as slotted Avatars, shown as "+N". You decide the truncation; 0 renders nothing.
hoverLiftbooleanfalseLifts an avatar on hover to reveal it above its neighbors.
motionAvatarGroupMotionHow it moves: its appearance, avatar by avatar ({ initial: { avatar: { opacity: 0, x: -8 } }, stagger: 0.04 }). Avatars you add or remove come and go the same way (key them). false turns its own animation off.
uiPartial<Record<'root' | 'overflow', UiPartValue>>Class and style overrides for each part.

Events

No events.

Slots

NameTypeDescription
defaultanyThe Avatars to stack.
overflow{ count: number; }Replaces the default "+N" content of the generated overflow avatar.

Exposed

NameTypeDescription
elHTMLElement | nullRoot element.
partsRecord<string, HTMLElement | HTMLElement[] | null>Its elements by part name, for your own animation; a repeated part is an array.

Motion New

AvatarGroup: its appearance, avatar by avatar.

<AvatarGroup
  :motion="{ initial: { root: { opacity: 0, y: 8 } }, stagger: 0.04 }"
/>
NameTypeDescription
initialexitrootavatarSets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate.
enterleave(parts, context) => animationAnimates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted.
staggerleavingappearnumber | 'pop' | 'hold' | booleanItems coming in together start stagger seconds apart. A leaving item lifts out so the rest close the gap ('pop'), or keeps its space until it's gone ('hold'). appear: true also brings in the items already there when it mounts.
springdurationeasing{ damping, response } | number | stringTimes all of it: a spring, or a duration in ms with an easing. Never both.
falsebooleanTurns its motion off, for an animation of your own on its exposed elements.

Accessibility

It has no keyboard interaction of its own.

  • The group is a <div> with no role. Each Avatar keeps its own alt.
  • Screen readers read the overflow avatar as its text, such as “+3”. The #overflow slot receives count if you want other wording.