Skip to content
Alpha

Hololink UI is under active development. Components, APIs and these docs may change without notice.

Holo Avatar

The <holo-avatar> component displays a user or entity’s image. When src is omitted, it falls back to rendering initials, or a generic decorative person icon if neither is provided.

Use it for:

  • Representing a person or entity beside their name, in comments, lists and headers.
  • Showing initials as a fallback when no image is available.

Don’t use it for:

  • Standalone identification. Always show the name as text nearby.
  • Status or counts. Use Badge or Tag.
  • Uploading or changing a profile picture. Avatar is display only and not interactive.
<holo-avatar src="https://example.com/ada.png" alt="Portrait of Ada B." size="md"></holo-avatar>
<holo-avatar initials="AB" size="md"></holo-avatar>
<!-- no src or initials: renders a decorative, aria-hidden icon -->
<holo-avatar></holo-avatar>

The avatar is not interactive. With src, the host has role="img" and renders an <img> whose alt comes from the alt prop (empty when omitted). With only initials, the host has role="img" and aria-label set to the initials. With neither, no role is set and the placeholder icon is aria-hidden, so assistive technology ignores it.

You provide:

  • A descriptive alt whenever you pass src, or an empty alt when the person’s name is already shown beside the avatar.
  • The full name as visible text near initials. Initials alone (for example “AB”) are announced as letters, not as a name.
  • Visible text for any meaning the image carries. Do not rely on the picture alone.

Importing

import '@philbob-sideprojects/hololink-ui/holo-avatar';

Properties

PropertyAttributeTypeDefaultDescription
altaltstring—Accessible text describing the image. Required when src is set.
initialsinitialsstring—Initials to render when no image is available.
sizesize"lg" | "md" | "sm"'md'The size of the avatar.
srcsrcstring—The image URL to display. If omitted, initials (or a generic icon) are rendered instead.

CSS custom properties

PropertyDescription
--holo-avatar-bgBackground color behind initials or the placeholder icon.
--holo-avatar-colorColor of the initials and placeholder icon.
--holo-avatar-radiusCorner radius of the avatar.
--holo-avatar-size-lgWidth and height of the lg size.
--holo-avatar-size-mdWidth and height of the md size.
--holo-avatar-size-smWidth and height of the sm size.