Data Display
Avatar
A square identity chip with an initials fallback, and an overlapping group with a counted overflow.
ARAR
Aditi Rao
Design
BKBK
Bilal Khan
Engineering
CWCW
Chen Wei
Product
ARBKCWand 5 more
8 reviewers on this releaseInstallation
Copy the source with the CLI to own and edit it, or import it from the npm package.
npx aback-ui@latest add avatarWrites components/ui/avatar.tsx. First time in this project? Run npx aback-ui@latest init first, as the installation guide shows.
Usage
Import the parts you need from the installed file. The Code tab above has a complete, working example.
import {
Avatar,
AvatarImage,
AvatarFallback,
AvatarGroup,
} from "@/components/ui/avatar";API reference
Props and composition points for Avatar. Native element props pass through.
| Prop | Type | Default | Description |
|---|---|---|---|
size | "xs" | "sm" | "default" | "lg" | "xl" | "default" | Sets the square footprint and the fallback type size. |
AvatarImage src / alt | string / string | None | Alt text is required when the avatar identifies a person. Use an empty alt for a decorative avatar. |
AvatarFallback | component | None | Rendered while the image loads and whenever it fails. Keep it to one or two initials. |
className | string | None | Layout adjustments only. |
AvatarGroup max / total / size | number / number / AvatarSize | None | Overlap avatars, collapse the rest into a +N count, and count people beyond the rendered ones. Size the count to match the avatars. |
Dependencies: radix-ui, plus the shared @/lib/utils helper.
Accessibility
Semantics, keyboard behavior, and the decisions that keep the component operable.
- The image keeps real alt text. If the person's name appears next to it, the avatar is decorative and the alt can be empty.
- Initials are a fallback, not a substitute for the name in the surrounding row.
- Do not signal presence or role with avatar colour alone; add text or a labelled status.
- The square shape is deliberate. Do not add rounded-full for a circle that conflicts with the system geometry.
- AvatarGroup is a group; name it with aria-label. The overflow count reads as "and 5 more".
Used in production
The Aback products whose interfaces shaped this component.