Avatar
Show a person or resource image with a fallback while the image loads.
Anatomy#
Usage#
Use Avatar where a person or resource needs a compact identity cue. Supply a meaningful alt for
identity images. Stack several people with AvatarGroup.
Image fallbacks#
The fallback shows while the image is loading, missing, or failed. text sets the fallback text,
typically initials. When text is blank or omitted, the fallback shows up to two initials taken
from alt. icon is an icon name that replaces the text for a generic placeholder.
Avatar renders the real <img src> during server rendering and uses native load and error events to
switch between image and fallback. size accepts sm, md (default), or lg.
Loading status#
The image status is loading, loaded, or error. An empty or missing src is error. Use
onStatusChange when surrounding UI must react to a source change. It fires after mount with the
initial status and on every change, and never on the server. Pair it with a status label owned by the
page.
Badge#
badge accepts an icon name. badgePosition places it in a corner: top-left, top-right,
bottom-left, or bottom-right (default). The badge icon is hidden from assistive technology, so
state the status in text when it matters.
Examples#
Fallback#
Provide alt and initials so the avatar falls back cleanly when src is missing or fails to load.
Loading status#
Use onStatusChange to track image loading states (loading, loaded, or error).
Icon fallback#
Pass icon as a fallback placeholder and handle error via onStatusChange when the image URL fails.
Badge#
Use badge and badgePosition to display a status indicator on the avatar. The icon is
decorative, so put the status in alt or nearby text.
API Reference#
Attributes#
data-statusProps#
Props for the Avatar component. Renders a <span> element by default.