Angular Avatar Component | ng-hub-ui-avatar

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

API reference

Here's the full contract for avatar: everything you can bind, listen to, project and theme, gathered in one place. Wire up what you need and style what you want — it's standalone and signal-friendly.

Inputs

Dial avatar in with 19 inputs. Bind them like any Angular @Input.

NameTypeDefaultDescription
sizestring | number50Avatar size in pixels
namestringUser name for generating initials when image sources fail
srcstring | SafeUrlPrimary custom image source URL for the avatar
altstringAlternative text for the avatar image for accessibility
roundbooleantrueWhether the avatar should be circular (true) or follow cornerRadius
bgColorstringBackground color for text avatars. Auto-generated if not provided
fgColorstring#FFFText color for initials in text avatars
borderColorstringBorder color around the avatar
cornerRadiusstring | number0Corner radius when round is false
textSizeRationumber3Ratio to calculate text size from avatar size (size / textSizeRatio)
initialsSizestring | number0Restricts the number of initials displayed (0 = no restriction)
facebookIdstringFacebook user ID for profile picture (best-effort, API restrictions may apply)
githubIdstringGitHub username for fetching profile picture
gravatarIdstringGravatar email or MD5 hash for fetching profile picture
valuestringDisplay a custom value as avatar (e.g., "75%", "+5")
stylePartial<CSSStyleDeclaration>Custom styles to apply to the avatar root element
referrerpolicystringReferrer policy for the avatar image (e.g., "no-referrer")
badgestring | number | boolean | nullCorner overlay: `badge` / `[badge]="true"` → a dot; `badge="4k"` → a labelled pill; null / absent → nothing.
badgeColorHubAvatarBadgeColor | string | nullSemantic colour of the badge (primary · secondary · success · danger · warning · info · light · dark) → `--hub-sys-color-*`.

Outputs

React to what avatar does — 1 events to hook your logic onto.

NameTypeDescription
clickOnAvatarSourceEmitted when avatar is clicked, returns the current active source object

Templates

No templates documented yet.

CSS variables

Theme every pixel with 11 CSS variables. Override them at :root or scope them to a wrapper.

Size & Layout

Control avatar dimensions and spacing

VariableDefaultTypeDescription
--hub-avatar-size50pxlength Default avatar size when no size is specified 24px40px64px96px
--hub-avatar-border-radius50%length Border radius for avatar container 04px8px50%

Colors & Appearance

Customize avatar colors and visual appearance

VariableDefaultTypeDescription
--hub-avatar-bg-colorvar(--hub-sys-color-primary)color Background color for text avatars #007bff#28a745#dc3545#6f42c1
--hub-avatar-text-color#ffffffcolor Text color for initials in text avatars #000000#ffffff#6c757d
--hub-avatar-border-colortransparentcolor Border color around avatar #dee2e6#007bff#28a745
--hub-avatar-border-width0length Border width around avatar 1px2px3px

Typography

Control text appearance in avatar initials

VariableDefaultTypeDescription
--hub-avatar-font-familyHelvetica, Arial, sans-serifstring Font family for avatar initials Inter, sans-serifRoboto, sans-serifsystem-ui
--hub-avatar-font-weightnormalstring Font weight for avatar initials 400500600bold
--hub-avatar-text-transformuppercasestring Text transformation for initials noneuppercaselowercasecapitalize

Custom content

Sizing of content projected into the avatar. Background and foreground come from the avatar's own tokens.

VariableDefaultTypeDescription
--hub-avatar-content-paddingcalc(var(--hub-avatar-size) * 0.2)length Padding between the projected content and the avatar edge. 8px15%calc(var(--hub-avatar-size) * 0.25)
--hub-avatar-content-icon-sizecalc(var(--hub-avatar-size) * 0.55)length Font size for projected icon fonts / emoji (inherited by the glyph). 1.5remcalc(var(--hub-avatar-size) * 0.6)

Styling and theming

No styling examples are documented yet. This section will include customization recipes and theming examples.