Skip to content

SiAvatarBackgroundColorDirective documentation

import { SiAvatarBackgroundColorDirective } from '@siemens/element-ng/avatar';

The directive provide a CSS variable --background with a color based on the initials or alt text.

Input Properties

NameTypeDefaultDescription
autoColor
boolean false

Automatically calculates the background color. If set, color will be ignored.

color
number undefined

The desired color index from $si-sys-color-data-categorical-* color tokens. This can be set to any kind of positive integer that is then mapped to a color index. A better way to set a pseudo-random color is to set autoColor to true.

Attributes and Methods

NameTypeDescription
calculateColorFromInitials()
(displayInitials?: string) => void

Update background color variable based on the initials or placeholder text.

Parameters

Except where otherwise noted, content on this site is licensed under MIT License.