Avatar

An image element with a fallback for representing the user.

RGRGRGRGRG+3

Installation

ng g @spartan-ng/cli:ui avatar

Usage

import { HlmAvatarImports } from '@spartan-ng/helm/avatar';
<hlm-avatar>
   <img hlmAvatarImage src='/assets/avatar.png' alt='spartan logo. Resembling a spartanic shield' />
   <span hlmAvatarFallback>RG</span>
</hlm-avatar>

Examples

Basic

A basic avatar component with an image and a fallback.

RG

NgOptimizedImage

The avatar image is rendered immediately and hidden until it loads, so Angular's NgOptimizedImage directive works with ngSrc as well as a regular src . The image is only visually hidden, not removed from the layout, so native lazy loading still loads it when it enters the viewport. Use fill to let the image fill the avatar.

RG

Badge

Use the hlm-avatar-badge component to add a badge to the avatar. The badge is positioned at the bottom right of the avatar.

RG

Badge Icon

You can also use an icon inside hlm-avatar-badge .

RG

Avatar Group

Use the hlm-avatar-group component to add a group of avatars.

RGRGRG

Avatar Group Count

Use hlm-avatar-group-count to add a count to the group.

RGRGRG+3

Avatar Group Icon

You can also use an icon inside hlm-avatar-group-count

RGRGRG

Sizes

Use the size prop to change the size of the avatar.

RGRGRG

Dropdown

You can use the hlm-avatar component as trigger for a dropdown menu.

RTL

To enable RTL support in spartan-ng, see the RTL configuration guide.

RGRGRGRGRG+٣

Brain API

BrnAvatar

Selector: [brnAvatar],brn-avatar

ExportAs: brnAvatar

BrnAvatarFallback

Selector: [brnAvatarFallback]

ExportAs: brnAvatarFallback

BrnAvatarImage

Selector: img[brnAvatarImage]

ExportAs: brnAvatarImage

Inputs

PropTypeDefaultDescription
hostStyles string 'position: absolute; inset: 0; width: 100%; height: 100%' Styles applied to the host element. Bound via `[style]` so they apply through the CSSOM and are not blocked by a strict Content-Security-Policy.

Helm API

HlmAvatarBadge

Selector: [hlmAvatarBadge],hlm-avatar-badge

ExportAs: hlmAvatarBadge

HlmAvatarFallback

Selector: [hlmAvatarFallback]

ExportAs: hlmAvatarFallback

HlmAvatarGroupCount

Selector: [hlmAvatarGroupCount],hlm-avatar-group-count

ExportAs: hlmAvatarGroupCount

HlmAvatarGroup

Selector: [hlmAvatarGroup],hlm-avatar-group

ExportAs: hlmAvatarGroup

HlmAvatarImage

Selector: img[hlmAvatarImage]

ExportAs: hlmAvatarImage

Inputs

PropTypeDefaultDescription
hostStyles string 'position: absolute; inset: 0; width: 100%; height: 100%' Styles applied to the host element. Bound via `[style]` so they apply through the CSSOM and are not blocked by a strict Content-Security-Policy.

HlmAvatar

Selector: [hlmAvatar],hlm-avatar

ExportAs: hlmAvatar

Inputs

PropTypeDefaultDescription
size 'default' | 'sm' | 'lg' 'default' -
Badge Autocomplete