Overlapping avatars where the hovered one rises, with a tooltip that glides from avatar to avatar.
Installation
The tooltips are Animate UI's Tooltip, positioned with Floating UI, a peer dependency of this primitive:
Usage
<script setup lang="ts">
import { AvatarGroup } from '@animate-ui/vue/primitives/avatar-group';
defineProps<{ people: { name: string; src: string }[] }>();
</script>
<template>
<AvatarGroup class="h-12 -space-x-3" invert-overlap>
<img
v-for="person in people"
:key="person.name"
:src="person.src"
:alt="person.name"
class="size-12 rounded-full border-3 border-background"
/>
</AvatarGroup>
</template>Each child is an avatar. Put an AvatarGroupTooltip inside an avatar to give it a tooltip:
<div class="size-12 rounded-full border-3 border-background bg-muted">
SK
<AvatarGroupTooltip class="rounded-md bg-foreground px-3 py-1.5 text-xs text-background">
<AvatarGroupTooltipArrow class="size-2.5 fill-foreground" />
<p>Skyleen</p>
</AvatarGroupTooltip>
</div>Animation
- The hovered (or pressed) avatar rises by
translateon a bouncy spring (stiffness 300, damping 17): it overshoots by about 17% before it settles, and dips below its place the same way when it comes back down. - The tooltips share one popup (Tooltip): it opens at once (
open-delayis 0) and glides from avatar to avatar on its spring (stiffness 400, damping 29), a little past the next avatar before it settles. <AnimateUIProvider :tempo>paces the default springs.- Under reduced motion, the avatar rises at once and the tooltip only fades.
API Reference
AvatarGroup
Takes the TooltipProvider and Tooltip props, with other defaults.
| Prop | Type | Default |
|---|---|---|
#default | slot | - |
invert-overlap? | boolean | false |
translate? | string | number | '-30%' |
transition? | Transition | { type: 'spring', stiffness: 300, damping: 17 } |
tooltip-transition? | Transition | { type: 'spring', stiffness: 400, damping: 29 } |
open-delay? | number | 0 |
close-delay? | number | 0 |
side? | "top" | "bottom" | "left" | "right" | "top" |
side-offset? | number | 25 |
align? | "start" | "center" | "end" | "center" |
align-offset? | number | 0 |
...props? | HTMLAttributes | - |
AvatarGroupTooltip
The TooltipContent props.
AvatarGroupTooltipArrow
The TooltipArrow props.
Credits
- Inspired by Jhey.