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).
Examples#
Recover a teammate when the photo is missing#
Keep alt and initials so the row still identifies the person if src fails.
Track profile image load status#
Drive nearby copy from onStatusChange when the page needs to know whether the photo loaded.
Fall back after a broken photo URL#
Set icon as a placeholder and read the error status when the stored URL 404s.
Mark verified and on-call teammates#
Use badge for a status glyph. Place it where it will not cover the face.
API Reference#
Attributes#
data-statusProps#
Props for the Avatar component. Renders a <span> element by default.