Overlapping avatars where the hovered one rises, with a tooltip that glides from avatar to avatar.
SK
CN
AW
GR
JH
DH
Installation
The tooltips are Animate UI's Tooltip, positioned with Floating UI, a peer dependency of this primitive:
Usage
import {
AvatarGroup,
AvatarGroupTooltip,
AvatarGroupTooltipArrow,
} from '@animate-ui/react/primitives/avatar-group';
export function Team({ people }: { people: { name: string; src: string }[] }) {
return (
<AvatarGroup className="h-12 -space-x-3" invertOverlap>
{people.map((person) => (
<img
key={person.name}
src={person.src}
alt={person.name}
className="size-12 rounded-full border-3 border-background"
/>
))}
</AvatarGroup>
);
}Each child is an avatar. Put an AvatarGroupTooltip inside an avatar to give it a tooltip:
<div className="size-12 rounded-full border-3 border-background bg-muted">
SK
<AvatarGroupTooltip className="rounded-md bg-foreground px-3 py-1.5 text-xs text-background">
<AvatarGroupTooltipArrow className="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 (
openDelayis 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 |
|---|---|---|
children | React.ReactElement | React.ReactElement[] | - |
invertOverlap? | boolean | false |
translate? | string | number | '-30%' |
transition? | Transition | { type: 'spring', stiffness: 300, damping: 17 } |
tooltipTransition? | Transition | { type: 'spring', stiffness: 400, damping: 29 } |
openDelay? | number | 0 |
closeDelay? | number | 0 |
side? | "top" | "bottom" | "left" | "right" | "top" |
sideOffset? | number | 25 |
align? | "start" | "center" | "end" | "center" |
alignOffset? | number | 0 |
...props? | React.ComponentProps<'div'> | - |
AvatarGroupTooltip
The TooltipContent props.
AvatarGroupTooltipArrow
The TooltipArrow props.
Credits
- Inspired by Jhey.