Showcase

Blazor Avatar

The Blazor Bootstrap Avatar component shows a person or entity as an image, initials, or an icon, with an optional status, and AvatarGroup stacks avatars with a "+N" overflow. The examples below cover image, initials and icon avatars, a broken-image fallback, sizes, shapes and colors.
API Documentation
INFO
Icon avatars use Bootstrap Icons, so reference the Bootstrap Icons stylesheet in your app. The broken-image fallback runs once the page is interactive; on a static server-rendered page a broken image stays as rendered.

Image, initials, and icon #

Avatar shows the image from ImageUrl. Without an image it shows initials from Name, then the icon from IconName, then a person icon.
How to use:
  1. Add Avatar and set Name. It gives the initials and the name screen readers announce.
  2. Set ImageUrl to show a photo.
  3. Set Initials when the computed ones are wrong, or IconName (or CustomIconName) for an icon.
  4. Leave Name empty for a decorative avatar, or name it with aria-label.
Initials use the first letter of the first and last words, so María José García would show MG; this example overrides it with MJ.

Broken image fallback #

When the image fails to load, the avatar falls back to the next source: initials, the icon, then the person icon.
How to use:
  1. Set ImageUrl together with Name or IconName so there is something to fall back to.
  2. Change ImageUrl at any time. The avatar tries the new image again, even after a failure.
Use the button to switch between a missing and a working image.

Sizes #

Avatars come in four sizes, and the --bb-avatar-size CSS custom property sets any other size.
How to use:
  1. Set Size to AvatarSize.Small, Medium (default), Large, or ExtraLarge.
  2. For a custom size, add Style="--bb-avatar-size: 6rem;". Initials and icons scale with it.

Shapes #

Avatars are circles by default and can also be rounded squares or squares.
How to use:
  1. Set Shape to AvatarShape.Circle, Rounded, or Square.

Colors #

Color sets the background of initials and icon avatars, with a readable text color in light and dark themes. It has no effect while an image is shown.
How to use:
  1. Set Color to an AvatarColor value. The default is Secondary; None removes the background.

Status #

A status dot at the bottom-end corner shows presence. The status is also part of the name screen readers announce, so it never relies on color alone.
How to use:
  1. Set Status to AvatarStatus.Online, Away, Busy, or Offline.
  2. Translate the announced text with OnlineText, AwayText, BusyText, and OfflineText.

Group with overflow #

AvatarGroup overlaps its avatars, shows at most Max of them, and adds a "+N" button for the rest. Hover the button to see the hidden names, or select it to open a list of them.
How to use:
  1. Wrap Avatar components in AvatarGroup.
  2. Set Max to the number of avatars to show. Leave it unset to show them all.
  3. Name the group for screen readers with aria-label or aria-labelledby.
  4. Translate the button's announced text with OverflowTextFormat, for example "{0} more".
The group follows avatars as they are added and removed. Hidden avatars without a name are counted but not listed.

Group size, shape, and overlap #

A group gives every avatar and the "+N" button the same size and shape. The overlap follows the size and mirrors in right-to-left layouts.
How to use:
  1. Set Size and Shape on AvatarGroup; they replace the values on each avatar.
  2. Change the overlap with Style="--bb-avatar-group-overlap: .25rem;".

Inside a grid #

Avatars and groups fit in Grid cells next to text.
How to use:
  1. Place an Avatar in a GridColumn template.
  2. Use AvatarSize.Small to keep rows compact.

Inside a dropdown and tooltip #

Avatars work in a Dropdown toggle and its items, and inside a Tooltip.
How to use:
  1. Put an Avatar in DropdownToggleButton or DropdownItem content, with a margin class such as me-2.
  2. Wrap an Avatar in a Tooltip to show more details on hover.

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please reload the page.