Avatar
Built on Base UI Avatar to manage image loading and fallback transitions. Provides three sizes, a status badge, overlapping groups, and a remaining-member count.
@neumorphism-ui/avatarPreview
SMAMUI
Team
ANDESO
+9
Installation
Installation: avatar
npx shadcn@latest add @neumorphism-ui/avatarThe CLI resolves npm dependencies, base tokens, utilities, and component source in order.
New to this Registry? Set up the namespace before continuing.
Usage
Import
Avatar import code
import {
Avatar,
AvatarBadge,
AvatarFallback,
AvatarGroup,
AvatarGroupCount,
AvatarImage,
} from "@/components/ui/avatar"Example
Avatar usage code
<AvatarGroup>
<Avatar size="lg">
<AvatarImage src="/members/ana.jpg" alt="Ana Martins" />
<AvatarFallback>AM</AvatarFallback>
<AvatarBadge aria-label="Online" />
</Avatar>
<Avatar size="lg">
<AvatarFallback>UI</AvatarFallback>
</Avatar>
<AvatarGroupCount aria-label="8 more members">+8</AvatarGroupCount>
</AvatarGroup>API Reference
| Component | Prop | Type | Default | Description |
|---|---|---|---|---|
Avatar | size | "sm" | "default" | "lg" | "default" | Changes the size of the Avatar and its badge together. |
AvatarImage | src | string | — | The URL of the image to display. |
AvatarImage | altrequired | string | — | Alternative text identifying the person or subject represented by the image. |
AvatarFallback | delayMs | number | 0 | The delay before the fallback is displayed. |
AvatarBadge | children | React.ReactNode | — | Displays a status dot or small status icon. |
Accessibility
- 01
Use the person's name as alt text for an identifying image; an empty alt is acceptable when the same name appears next to it.
- 02
If AvatarBadge conveys meaning such as online status, provide an aria-label or visually hidden text.
- 03
Add an aria-label that explains the meaning of a count such as +8 in AvatarGroupCount.