Avatar
Profile pictures with initials fallback, status badges, groups that lift on hover and colored letter avatars for members.
Preview
Usage
import {
Avatar,
AvatarFallback,
AvatarImage,
} from '@vitnode/core/components/ui/avatar'<Avatar>
<AvatarImage alt="Ada Lovelace" src={user.avatarUrl} />
<AvatarFallback>AL</AvatarFallback>
</Avatar>Fallback
The fallback shows while the image loads and stays if it never arrives. Once loaded, the image fades in instead of popping.
Sizes
<Avatar size="sm" />
<Avatar />
<Avatar size="lg" />Badge
AvatarBadge adds a status dot. Give it a semantic background:
<Avatar>
<AvatarImage alt="Ada Lovelace" src={user.avatarUrl} />
<AvatarFallback>AL</AvatarFallback>
<AvatarBadge className="bg-success" />
</Avatar>A dot alone doesn't tell everyone someone is online. Say it in text too, or
give the badge an aria-label.
Group
AvatarGroup stacks avatars. Wrap each in AvatarGroupItem to lift it on
hover and show a tooltip, and end with AvatarGroupCount:
import {
AvatarGroup,
AvatarGroupCount,
AvatarGroupItem,
} from '@vitnode/core/components/ui/avatar'<AvatarGroup>
{users.map((user) => (
<AvatarGroupItem key={user.id} label={user.name}>
<Avatar>
<AvatarImage alt={user.name} src={user.avatarUrl} />
<AvatarFallback>{user.initials}</AvatarFallback>
</Avatar>
</AvatarGroupItem>
))}
<AvatarGroupCount>+3</AvatarGroupCount>
</AvatarGroup>The whole group shares one tooltip, so it glides from face to face. Plain
Avatars inside a group make a quiet stack with no hover effect.
Member avatars
For VitNode users, reach for Avatar from @vitnode/core/components/avatar.
It shows the stored picture, or the first letter of nameCode on the
member's avatarColor in white.
import { Avatar } from '@vitnode/core/components/avatar'<Avatar size={32} user={user} />user needs name, nameCode, avatarColor (hex without #) and an
optional avatarUrl. A broken avatarUrl falls back to the letter.
Accessibility
- Always pass
alttoAvatarImage. The person's name is usually perfect. - An
AvatarGroupItemwith alabelis focusable, and its tooltip opens on focus as well as hover. - With reduced motion, group avatars stay put and only the tooltip appears.
Props
Avatar
Prop
Type
AvatarGroupItem
Prop
Type