Avatar
A person or entity as an image with initials as the fallback, plus a group with a labelled overflow count. Built on Base UI.
Usage
import { Avatar, AvatarGroup } from "@azmr/ui/avatar";import { Avatar, AvatarGroup } from "@azmr/ui/avatar";
const team = ["Aroha Ngata", "Mere Walker", "Hemi Te Rangi", "Tane Smith", "Rangi Bell"];
export default function AvatarBasic() {
return (
<div className="flex flex-col gap-6">
<div className="flex items-end gap-3">
<Avatar name="Aroha Ngata" size="sm" />
<Avatar name="Aroha Ngata" />
<Avatar name="Aroha Ngata" size="lg" />
<Avatar name="Aroha Ngata" size="xl" shape="square" />
</div>
{/* An image that cannot load falls back to the initials, still labelled. */}
<Avatar src="/does-not-exist.png" name="Mere Walker" />
<AvatarGroup max={3} aria-label="Project team">
{team.map((person) => (
<Avatar key={person} name={person} />
))}
</AvatarGroup>
</div>
);
}When src is missing, still loading, or fails (offline, a 404), the initials of name are shown instead, so an avatar never turns into a broken-image icon. getInitials is exported: the first character of the first two words, uppercased, counting whole characters so an emoji or a rare character is never cut in half. Pass fallback to show something else, and delayMs to avoid a flash of initials while a fast image loads.
Naming
An avatar must say who it is, so the types require one of name, alt or decorative:
namelabels the avatar and supplies the initials.altoverrides the label ("Aroha, account owner").decorativehides it from assistive technology, for an avatar beside a name that already says who it is.
The avatar element carries the label; the image inside is alt="" so it is not announced twice.
AvatarGroup
AvatarGroup overlaps its avatars and shows at most max, then a +N avatar labelled "N more" (overflowLabel to localise). It is a role="group": give it an aria-label ("Project team").
Props
Prop
Type
Accessibility
role="img"with the name as its label, oraria-hiddenwhen decorative.- The overflow avatar says how many people are hidden.
- No keyboard interaction; put an avatar inside a button or link when it should be interactive, and give that control the name.
Floating
Tooltip, Popover and HoverCard. Surfaces anchored to a trigger, collision-aware, portalled, and animated with the motion tokens. Built on Base UI.
Progress
A linear or circular progress indicator with a required name, a determinate and an indeterminate state, and tones that stay visible against the track.