Avatar
User image with an initials fallback when it fails to load.
Base UI reference ↗Installation
Run it from the root of a project already set up with zunoui init.
npx zunoui@latest add avatarDependencies
What add avatar installs alongside the component. The CLI skips any you already have in a compatible version.
ZUNO registry
@zuno/utils
npm
@base-ui/[email protected]
Examples
3 examples · 1 componentImage with fallback
If the image fails to load, the initials are shown.
Sizes
Three sizes: sm (32 px), default (40 px) and lg (48 px). The fallback font scales with the avatar.
Stacked group
Several overlapping avatars composed together.
API reference
Keeps the props, events and refs of the matching Base UI primitive, plus ZUNO's styles.
| Prop | Type | Default |
|---|---|---|
AvatarRound container; control its size with the size prop. | span | — |
sizeAvatar size: 32, 40 or 48 px, with the fallback font scaled to match. | "sm" | "default" | "lg" | "default" |
AvatarImageImage; fades in when loaded and hides if it fails. | img | — |
AvatarFallbackAlternative content (initials or an icon). | span | — |
States
The states that apply to this component and their visual treatment.
| State | Treatment |
|---|---|
| Loading | Shows the fallback while the image loads. |
| Loaded | The image fades in and covers the container. |
| Fallback | If the image fails, the initials or an icon remain. |
Accessibility
Give AvatarImage a descriptive alt with the person's name.
The fallback appears while the image loads or if it fails; use initials or an icon, not color alone.