Avatar
Shows a person's photo, falling back to initials or an anonymous person icon.
Show codeHide code
Installation
import { Avatar } from "@makeplane/propel/components/avatar";Usage
import { Avatar } from "@makeplane/propel/components/avatar";
export default function BasicDemo() {
return (
<Avatar size="md" alt="Ada Lovelace" fallback="AL" src="https://i.pravatar.cc/128?img=47" />
);
}Examples
At 2xs (16px), derived initials and string fallback values display only their first Unicode grapheme. Larger sizes retain their initials. Custom React fallback content is rendered as supplied; keep it suitable for the available space.
Sizes
size is an optical ramp of eight steps — 2xs 16 / xs 20 / sm 24 / md 28 / lg 32 /
xl 40 / 2xl 56 / 3xl 64 px — not the control ladder. The four middle steps happen to agree
with the ladder’s labels; the extremes are Avatar’s own. md is the default, and inside an
AvatarGroup the group’s size wins unless an avatar sets its own.
Show codeHide code
Variants
The initials background variant is derived stably from alt (falling back to the initials themselves), so every member gets a consistent color automatically — it is not a consumer prop.
Show codeHide code
States
The three fallback states side by side: photo, initials, and the anonymous person icon. Content resolves in that fixed order, so a photo that fails to load drops to initials rather than leaving a broken frame.
Initials are derived from alt when you don’t pass fallback — up to two characters, the first letter of the first and last name token, uppercased. A single-token name yields one letter. The anonymous icon is reached only when no name resolves at all.
Show codeHide code
With tooltip
Pass tooltip to show the person’s name on hover. true reuses alt; a string is the label and works without alt.
An avatar stays presentational either way: a tooltip does not put it in the tab order. When the avatar is genuinely interactive — opening a profile, a menu, a member picker — wrap it in a button or link and let the wrapper own focus, so the focus ring is not clipped by the circular mask.
Show codeHide code
Interactive avatar
Put the tooltip on the actionable wrapper so keyboard focus reveals the same information as hover. The wrapper owns the accessible action name and a target of at least 24px; the avatar inside is decorative. Connect the button’s onClick to the consumer’s profile action.
Show codeHide code
Consumer tabIndex is forwarded for compatibility, but avoid adding tab stops to avatar artwork, especially decorative aria-hidden avatars. Put interaction, focus and tooltip semantics on a named button or link wrapper.
Migration guidance is maintained in the 0.5.0 changelog entry.
API Reference
Avatar
The ready-made avatar: an image that falls back to initials (or an anonymous person icon),
composed from the elements/avatar parts (Avatar root + AvatarImage + AvatarFallback).
Pass src for the photo and fallback for initials; the initials color is chosen automatically
and is not a consumer prop.