Angular Avatar Component | ng-hub-ui-avatar

Angular avatar component with initials, fallback images, presence badges and CSS variables for reusable user identity interfaces.

Interactive examples

Explore live examples that show how the library behaves in common Angular use cases.

Avatar Sources

Resolve avatars from social profiles, custom images, name initials or a custom value, with automatic fallback.

Facebook Profile

Gravatar

GitHub Profile

Custom Image Source

Name Initials

JD

Value Display

75%

Fallback System

Gracefully degrade through every configured source until a meaningful representation is shown.

Fallback System

Fallback Initials

Showing GitHub source (Facebook ID invalid)

Sizing

Control avatar dimensions, the text-to-size ratio and how many initials are rendered.

Custom Size

SD
RS
3.5rem
CS
calc(2rem + 12px)
PS
72 (pixels)

Text Size Ratio

RD

Initials Size Limit

JD

Styling

Shape, corner radius, colours, borders and arbitrary inline styles — all driven by inputs and CSS variables.

Round Avatar

R

Corner Radius

R

Background & Foreground Color

C
Custom BG & FG (inputs)
TD
Themed via --hub-avatar-bg-color ([autoColor]="false")

Contrast-safe initials

The automatic palette, as it paints today

Eight names, one per palette slot. Each avatar writes black or white on the colour its name hashed to, and the first ratio below it is read back from the two colours the browser actually painted. The second is what white initials would have scored on that same colour — what the component forced before 22.14.0, and what six of these eight would still be doing.

  • GH
    measuring…
  • AL
    measuring…
  • LT
    measuring…
  • BL
    measuring…
  • DK
    measuring…
  • AT
    measuring…
  • KT
    measuring…
  • AB
    measuring…

Those six are stated rather than shown on purpose: a row of white-on-yellow initials would be a page about readable labels printing six unreadable ones. An explicit fgColor does still win, contrast or not — that is how you pin the old look, and the snippet below is all it takes.

A palette the library has never seen

#ffcc00, #cccccc and #004080 — three colours the library ships no knowledge of. An application hands them to provideAvatar({ colors }) once at bootstrap; this demo scopes the same palette to its own avatars so it does not repaint the rest of the page. Either way the ink is derived from whatever colour ends up behind the text, so the guarantee travels with the background rather than with a list of approved pairings.

  • VR
    measuring…
  • IN
    measuring…
  • RP
    measuring…

Border Color

B

Custom Styles

S

Interactivity

React to user interaction with the avatar click event.

Click Event Handler

CM
Click the avatar, or focus it and press Enter…

Groups & badge

Stack avatars into a group, and overlay a corner badge — a presence dot or a labelled count — coloured by the semantic palette.

Avatar Group Display

A
B
C
+3

Badge (dot & count)

AL
GH
AT
LT
CMF
4k
JD
9+

Custom content

Project any icon, inline SVG, image or emoji inside the avatar. It is centered, padded and clipped to the avatar shape, sized agnostically (font icons scale, SVG/images fill) and themed with the regular bgColor / fgColor inputs.

Custom content (icons, SVG)

🚀