Introducing PrimeReact v11-alpha 🎉Discover Now

Avatar

Avatar represents people using icons, labels and images.

A
A
preview

Installation#

npx shadcn@latest add @primereact/avatar

Usage#

import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
<Avatar>
    <AvatarImage src="https://primefaces.org/cdn/primevue/images/avatar/avatar-1.png" />
    <AvatarFallback>CC</AvatarFallback>
</Avatar>

Examples#

Basic#

A
basic-demo

Fallback#

The Avatar.Fallback component displays a label or an icon when an image fails to load or when an image is not preferred.

J
CC
fallback-demo

Image#

The Avatar.Image component displays an image as an Avatar.

A
A
O
image-demo

Badge#

Badge component can be used to display a badge on an Avatar.

O
2
W
badge-demo

Shape#

Use the shape property to change the appearance.

W
W
shape-demo

Sizes#

Use the size property to change the size of an avatar.

AB
AB
AB
AB
AB
AB
size-demo

AvatarGroup#

Grouping is available by wrapping multiple Avatar components inside an Avatar.Group component.

A
A
O
I
X
+2
group-demo

Accessibility#

Screen Reader#

Avatar does not include any roles and attributes by default. Any attribute is passed to the root element so you may add a role like img along with aria-labelledby or aria-label to describe the component. In case avatars need to be tabbable, tabindex can be added as well to implement custom key handlers.

Keyboard Support#

Component does not include any interactive elements.