Avatar

<wa-avatar> Stable Since 2.0

Avatars represent a person or object with an image, initials, or icon. Use them in lists, comments, and profiles to give users visual context at a glance.

By default, a generic icon will be shown. You can personalize avatars by adding custom icons, initials, and images. You should always provide a label for assistive devices.

Examples

Link to This Section

Images

Link to This Section

To use an image for the avatar, set the image and label attributes. This will take priority and be shown over initials and icons. Avatar images can be lazily loaded by setting the loading attribute to lazy.

Initials

Link to This Section

When you don't have an image to use, you can set the initials attribute to show something more personalized than an icon.

Custom Icons

Link to This Section

When no image or initials are set, an icon will be shown. The default avatar shows a generic "user" icon, but you can customize this with the icon slot.

Shapes

Link to This Section

Avatars can be shaped using the shape attribute.

Avatar Groups

Link to This Section

You can group avatars with a few lines of CSS.

Importing

Link to This Section

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick a component manually, use one of the following snippets.

CDN npm Self-Hosted React

Import this component directly from the CDN:

import 'https://ka-f.webawesome.com/[email protected]/components/avatar/avatar.js';

After installing Web Awesome via npm, import this component:

import '@awesome.me/webawesome/dist/components/avatar/avatar.js';

If you're self-hosting Web Awesome, import this component from your server:

import './webawesome/dist/components/avatar/avatar.js';

To import this component for React 18 or below, use the following code:

import WaAvatar from '@awesome.me/webawesome/dist/react/avatar/index.js';

Slots

Link to This Section

Learn more about using slots.

Attributes & Properties

Link to This Section

Learn more about attributes and properties.

Events

Link to This Section

Learn more about events.

CSS custom properties

Link to This Section

Learn more about CSS custom properties.

CSS parts

Link to This Section

Learn more about CSS parts.

Dependencies

Link to This Section

This component automatically imports the following elements. Sub-dependencies, if any exist, will also be included in this list.

Need a hand? Report a bug Ask for help
    No results