Dark Light
System
Default LBBW Jira Confluence Source Code
Share
Playground

Avatar

<afp-avatar> Since 1.0.0 stable This component uses the light DOM, so its markup and styles are part of the regular document flow.

An avatar component to display user profile images with initials fallback.

Examples #

Variants #

The avatar component supports different variants using the variant attribute.

Shapes #

use the shape attribute to change avatar's shape.

Sizes #

Use the size attribute to change an avatar's size.

Images #

Display an avatar with a custom image using the image attribute.

Initials #

Display an avatar with user initials using the name attribute.

Custom Default Icon #

Use the icon slot within the avatar to display custom default icons.

With Tooltip #

Add a tooltip using the title attribute.

Disabled #

Disable an avatar using the disabled attribute.

Properties

Learn more about properties.

Name Description Reflects
image
The URL of the image to be displayed inside the avatar.
Type string
name
A placeholder for initials when no image is available. Initials are generated based on the name assigned to this property, typically limited to 1–2 characters for best readability.
Type string
shape
shape of the avatar
Type
AfpShape
Name Description
PILL
Makes the component circular.
ROUNDED
Makes the component rounded.
SOFT
Makes the component have soft edges.
SQUARE
Makes the component square.
AfpShape
Default AfpShape.CIRCLE
variant
variant of avatar (color/appearance)
Type
AfpVariant
Name Description
NEUTRAL
The main call-to-action.
BRAND
Less prominent than primary.
ACCENT
Secondary highlight for emphasis.
ERROR
Used for destructive or critical actions.
INFO
Conveys general information.
SUCCESS
Indicates a successful or positive action.
WARNING
Communicates cautionary actions.
AfpVariant
Default AfpVariant.NEUTRAL
size
size of the avatar
Type
AfpSize
Name Description
SMALL
Small size with compact dimensions.
MEDIUM
Medium size with standard dimensions.
LARGE
Large size with expanded dimensions.
AfpSize
Default AfpSize.MEDIUM
disabled
Disabled property of avatar.
Type boolean
label
A label that describes the avatar for assistive devices.
Type string
title
The title of a browser-specific tooltip when provided.
Type string

Slots

Learn more about slots.

Name Description
icon
The default icon slot when no image or initials are provided.

Internationalization

Learn more about internationalization.

Key Description
avatar.aria-label
The default `aria-label` text for Avatar
avatar.img.alt
The default image `alt` text for Avatar

CSS Parts

Learn more about CSS Parts.

Name Description Selector
base
The avatar element wrapper.
::part(base)
image
The image element when an image is provided.
::part(image)
initials
The initials container when image is not provided.
::part(initials)
default-icon
The default icon when no image or initials are provided.
::part(default-icon)

CSS Custom Properties

Name Description Default
--afp-avatar-disabled-opacity
The opacity of the avatar when disabled.
0.5
--afp-avatar-border-color
The border color of the avatar.
--afp-color-body
--afp-avatar-border-width
The border width of the avatar.
--afp-border-width-m

Dependencies

The component automatically brings in the listed items, including any nested dependencies that may exist.

afp-icon

Importing

Using the bundle is the recommended method to include components. If you’d rather handle imports manually, you can use the code examples below.

import '@afp-design-system/core/dist/components/avatar/avatar.js';
Share
Create a link with a predefined theme that is automatically applied when the generated link is opened. Default LBBW Presentation Mode
Abort Copy Link