Skip to content

Avatar

Displays a user or entity image with a fallback option.

First release: 1.0.0 Latest update: July 1, 2025 Current version: 1.0.0

React Angular Vue Svelte HTML

Import

import { PlusAvatar } from '@plusui/react';
import { PlusAvatarComponent } from '@plusui/angular';
import { PlusAvatar } from '@plusui/vue';
import PlusAvatar from '@plusui/svelte';
<script src="https://cdn.jsdelivr.net/npm/@plusui/core"></script>

Package

@plusui/react
@plusui/angular
@plusui/vue
@plusui/svelte
@plusui/core

Docs

Changelog

Avatar Changelog

Recent changes and updates for the avatar component

v1.0.0

June 20, 2025
Feat

Added Avatar component for user representation

  • Image, icon, and text fallbacks
  • Multiple sizes: xs, sm, md, lg, xl
  • Circle and square shapes
  • Inverted color scheme support

The Avatar component displays an image representing a user or entity. It supports images, icons, or initials as fallback content when an image isn’t available or fails to load.

Avatar - anatomy
Show code

The size prop controls the dimensions of the avatar. It accepts predefined values (xs, sm, md, lg, xl) or any valid CSS size unit.

Show code

The shape prop determines the overall shape of the avatar.

Show code

When an image is not provided or fails to load, the avatar displays fallback content based on the fallbackStrategy prop. You can provide text for initials or use the default icon (customizable via the icon prop).

Show code

Proper layout and spacing are crucial for integrating avatars seamlessly into the UI.

Avatar - layout spacing 1 Avatar - layout spacing 2 Avatar - layout spacing 3

The Avatar component adapts to both light and dark themes.

Avatar - light & dark mode
  • Keyboard Behavior: The component itself is not typically interactive, but if used within an interactive element (like a button or link), ensure that element follows standard keyboard navigation patterns.
  • Screen Reader: The role="img" is automatically applied. Provide meaningful alternative text via the alt prop, especially when an image is used. If alt is absent, the component attempts to use the text prop or a generic label, but explicit alt text is always recommended for clarity.
  • Developer Actions: Always provide a descriptive alt prop when using the image prop. Ensure sufficient color contrast between the avatar background and foreground (text/icon) if customizing colors.
NameTypeDefaultDescription
imagestringundefinedURL of the avatar image.
altstringundefinedAlternative text for the image.
shape'circle' | 'square''circle'Shape of the avatar.
size'xs' | 'sm' | 'md' | 'lg' | 'xl' | string'md'Size of the avatar (predefined or custom CSS unit).
iconstring'fa-solid fa-user'CSS class for the fallback icon.
invertbooleanfalseToggles the inverted color scheme.
textstringundefinedText to display as initials.
fallbackStrategy'icon' | 'text' | 'custom''icon'Strategy when image fails to load.
NamePayload TypeDescription
errorCustomEvent<void>Fired when the image fails to load.
loadCustomEvent<void>Fired when the image loads.
NameDescription
(default)Main content area (image, icon, or text).
fallbackCustom content for fallbackStrategy='custom'.
NameDescription
--text-colorText color for initials or icon.
--bg-defaultDefault background color.
NameDescription
baseThe main container element.

Join the Community

Plus UI is built by the community. Join us on our platforms to contribute, get help, and stay up to date.