Data display

Avatar

A small circle with a profile image or initials.

Class nameTypeDescription
avatarplf:avatarComponentA round profile picture
avatar-imageplf:avatar-imagePartThe profile image
avatar-fallbackplf:avatar-fallbackPartInitials in place of an image
avatar-smplf:avatar-smSizeSmall
avatar-lgplf:avatar-lgSizeLarge

Default

Give an image that identifies someone a meaningful alt.

Alex Morgan
Alex Morgan Alex Morgan Alex Morgan

Initials

Initials do not name a person, so give the avatar role="img" and the full name in aria-label.

Missing images

Avatar does not detect a failed image: your code hides the image with hidden and shows an avatar-fallback.

Alongside a name

Beside a visible name, as in this Item, the image is decorative: give it alt="".

Alex Morgan

Workspace administrator

React

Avatar from @pelatform/react renders this markup from its props, and each part is a component of its own.

Prop Values Default
size sm, lg The default size

The parts:

Part Element
AvatarImage An img with avatar-image
AvatarFallback A span with avatar-fallback and aria-hidden="true", which hides its initials from screen readers

Other props are the element’s own, className and ref included.

CSS variables

Override on a root or on a single avatar.

Variable Default
--plf-avatar-size 2.5rem (40px); 2rem (32px) with avatar-sm, 3rem (48px) with avatar-lg
--plf-avatar-font-size --plf-font-size-sm (14px); --plf-font-size-xs (12px) with avatar-sm, --plf-font-size-body (16px) with avatar-lg
--plf-avatar-bg Muted surface
--plf-avatar-color Text
--plf-avatar-border --plf-color-border-subtle

Built with Pelatform UIv0.1.0

Components

Getting started

Foundations

Components

Actions

Data display

Navigation

Feedback

Data input

Layout

Advanced

Integrations

Blocks

Application

Authentication

Icons