Skip to content

Avatar

Displays a user or object avatar, supporting both text-placeholder and image forms.

Basic Usage

Text avatars

ABCD

A text avatar renders the first character of its content; with no content at all, it shows a ? placeholder.

Sizes

Size variants

ABCDE

Image Avatars

Image avatars

Avatar Groups

Avatar group

AB

Multiple oas-avatar elements wrapped in oas-avatar-group are laid out left-to-right with overlapping.

Max display count

ABC

When max is set, the overflow is hidden and a +N count badge is shown at the end.

Unified Size

size sets the size of all avatars in the group (px) so it does not need to be set per avatar; combined with max, the +N count badge adapts its size accordingly.

Unified size size

ABABCD

Badge Overlay

badge overlays a badge on the avatar's top-right corner (text or boolean); the boolean form (no value) shows a small dot; badge-dot forces the dot variant; badge-color switches colors; badge-placement moves the badge to the bottom-right.

Text badges

ABCD

Dot badges

EFG

Placement and image avatars

Load-Failure Fallback

When the image fails to load, the avatar automatically falls back to a placeholder: first the fallback named-slot content, then the first character of its content, and finally ?.

Fallback to first character

A

Custom fallback slot

!

Empty Fallback

Empty fallback

M

API

oas-avatar

AttributeDescriptionTypeDefault
altAlternative text for the image
badgeBadge text overlaid on the avatar's top-right corner; boolean form (no value) shows a dotstring
badge-colorBadge color: primary/success/warning/dangerstringdanger
badge-dotSmall dot badge variant (no text)boolean
badge-placementBadge placement: top-right (default) / bottom-rightstringtop-right
sizeAvatar size (px)string32
srcImage URL; renders an image avatar when presentstring
NameDescription
fallbackCustom placeholder content when the image fails to load (or the avatar has no content)

oas-avatar-group

AttributeDescriptionTypeDefault
maxMax number of avatars shown; overflow shows a +N count badgestring
sizeUnified avatar size (px); the count badge adaptsstring
NameDescription
default

Note: alt is read on first render and is not in the observed attribute list; dynamic changes require a manual re-render.

Released under the MIT OR Apache-2.0 License.