Avatar with motion: a new picture crosses over the old once it has loaded, a change of status pops the dot with one ripple, and AvatarGroup spreads apart on hover and makes room as people join or leave.
$ pnpm dlx shadcn@latest add @dashral/motion-avatarInstallation
$ pnpm dlx shadcn@latest add @dashral/motion-avatarAdds components/dashral/motion/avatar.tsx, the Avatar it builds on (in components/dashral/), motion and the motion files every motion component shares. Or by its full URL: https://dashral.com/r/motion-avatar.json
Usage
The same as Avatar, imported from components/dashral/motion/ (with the npm package: @dashral/motion/components/avatar): swap the import and it moves.
import { Avatar, AvatarGroup } from "@/components/dashral/motion/avatar"
<Avatar src={user.photo} name={user.name} status={user.status} />
<AvatarGroup items={members} max={4} showNames />Examples
Your status
Pick a status and the dot pops in its color with one ripple; On a call keeps a gentle ripple going (pulse); Change photo crosses the new one over the old.
Compared with Default
A picture fades in once; a new one replaces it at once. A new status changes the dot's color at once, and a group's stack stays put.
Motion
A new picture crosses over the old once it has loaded, a new status pops the dot with one ripple, and a group spreads on hover and makes room as people join or leave.
How the two editions differ in general, and which to use where: Motion.
API reference
Every prop of Avatar, and every attribute of the element it renders. What the Motion edition adds is marked Motion.
Avatar
Also takes every prop of Radix Avatar(opens in a new tab).
| Prop | Type | Default |
|---|---|---|
pulse | boolean
| false |
src | stringThe photo. | — |
name | stringWho it is: the alt text, and the initials shown while the photo loads or without one. | — |
alt | stringThe image's alt text; "" when the name is written beside it. | name |
fallback | ReactNodeReplaces the initials, e.g. an icon. | the initials |
size | "xs" | "sm" | "md" | "lg" | "xl"24, 28, 32, 40 or 64px. | "md" |
shape | "circle" | "square" | "circle" |
status | "online" | "away" | "busy" | "offline"A dot in the corner, read out too. | — |
classNames | { image, fallback, status }Classes for each part. | — |
className | stringExtra classes, merged with cn() so yours win. | — |
AvatarGroup
Also takes every prop of <div>(opens in a new tab).
| Prop | Type | Default |
|---|---|---|
items | { src?, name?, fallback?, id? }[]The people. Required. | — |
max | numberAvatars shown before the rest collapse into “+N”. | — |
size | "xs" | "sm" | "md" | "lg" | "xl" | "md" |
showNames | booleanEach avatar shows its name in a tooltip, and “+N” lists the rest. | false |
className | stringExtra classes, merged with cn() so yours win. | — |
Motion
- A picture loads before it shows, then fades in over the initials in 0.32s; a new picture loads first and crosses over the old, which stays until the new one has come in, so nothing goes blank.
- A change of status pops the dot from half its size in its new color (0.3s, a smooth curve) and sends one ripple out from it; pulse keeps a slow ripple going every 2.4s. The first status just shows.
- AvatarGroup spreads apart under the pointer or keyboard focus (each overlap easing from -8px to 2px), the avatar under the pointer rising 2px; avatars that join fade and grow in while the rest glide to make room, ones that leave fade out as the rest close up, and +N rises into its new count.
- With reduced motion, pictures only fade, nothing ripples and the group doesn't spread.