Component

Avatar

A compact portrait for a person or entity — an image with initials as a fallback, an optional status dot or badge, and hb-avatar-group to stack several with an overflow count.

Image, fallback & shape

Kauan HerbstNAQ
import { ChangeDetectionStrategy, Component } from '@angular/core';

import { HbAvatarImports } from '@herbst/ui';

const portrait =
  'data:image/svg+xml,' +
  encodeURIComponent(
    "<svg xmlns='http://www.w3.org/2000/svg' width='80' height='80'>" +
      "<defs><linearGradient id='g' x1='0' y1='0' x2='1' y2='1'>" +
      "<stop offset='0' stop-color='#A64B2A'/><stop offset='1' stop-color='#6B7A55'/>" +
      '</linearGradient></defs>' +
      "<rect width='80' height='80' fill='url(#g)'/></svg>",
  );

@Component({
  selector: 'hb-demo-avatar-basic',
  imports: [HbAvatarImports],
  template: `
    <div class="flex items-center gap-4">
      <hb-avatar [hbSrc]="portrait" hbAlt="Kauan Herbst" hbFallback="KH" hbPriority hbSize="lg" />
      <hb-avatar hbFallback="NA" hbSize="lg" />
      <hb-avatar hbFallback="Q" hbShape="square" hbSize="lg" />
    </div>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class HbDemoAvatarBasicComponent {
  protected readonly portrait = portrait;
}

Sizes

XSSMMDLGXL72

Status & badge

ONAWBSOFOK99 9+

Group & overflow

KHNABS

Overflow clicks: 0

Clickable & disabled

KHNA

Tapped 0×

API reference

hb-avatar — inputs

PropertyDescriptionTypeDefault
[hbSrc] Image URL; the fallback shows while loading or on error. string ''
[hbAlt] Alt text for the image. string ''
[hbFallback] Initials or text shown when there is no image. string ''
[hbPriority] Mark the image as high priority to load eagerly. boolean false
[hbSize] Named size, or a number in pixels. 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number 'md'
[hbShape] Circle or rounded square. 'circle' | 'square' 'circle'
[hbStatus] Presence dot colour. 'online' | 'offline' | 'away' | 'busy' undefined
[hbBadgePosition] Corner of the status dot or badge. 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' 'bottom-right'
[hbBadgeIcon] Icon name shown inside the badge. string ''
[hbDisabled] Dim the avatar and block clicks. boolean false

hb-avatar — outputs & slots

PropertyDescriptionTypeDefault
(hbClick) Emitted when the avatar is clicked. void
[hbAvatarBadge] Projected custom badge (a count, dot, or icon). slot

hb-avatar-group

PropertyDescriptionTypeDefault
[hbMax] Show at most this many avatars; the rest collapse into an overflow tile. number | null null
[hbSpacing] How much the avatars overlap. 'sm' | 'md' | 'lg' 'md'
[hbSize] Size applied to every avatar in the group. 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number 'md'
[hbShape] Shape applied to every avatar in the group. 'circle' | 'square' 'circle'
[hbOrientation] Stack the avatars in a row or a column. 'horizontal' | 'vertical' 'horizontal'
[hbOverflowIcon] Icon shown in the overflow tile instead of the count. string ''
(hbOverflowClick) Emitted when the overflow tile is clicked. void