AppAvatar
A picture of a person or a team, with initials on a tinted disc when there is no picture or it fails to load. The tint comes from the name (or a seed you pass), with the same hash and the same eight hues as AdvancedAppTable's identity column, so a person keeps one colour everywhere; initials stay at 4.5:1 on their tint in all six preset and theme combinations. The avatar is one image to screen readers, named by name and status ("Ada Lovelace, Online"). The optional status dot has a shape for each state as well as a colour: online a disc, away a crescent, busy a bar, offline a ring.
Install: pnpm add-component AppAvatar
Hover for the name
tooltip shows the name and the status word in an AppTooltip ("Grace Hopper, Busy"); it flips when its side has no room. For a row of faces, use AppAvatarGroup: it reveals each name with the blob.
Pictures and initials
A photo; initials (two letters from the first and last word, or one); a picture that fails to load falls back to initials; non-Latin names keep their letters; no name shows a person glyph.
Sizes and shapes
Status
The name is written beside each avatar, so alt is '' and screen readers hear the status alone. The dot sits on a ring cut in --vt-avatar-cut (default --color-surface); set it to the colour behind the avatar.
API
name(string): Who or what it is. Drives the initials, the tint and the accessible name. Empty shows a person glyph.src(string): Picture URL. When it is missing or fails to load, the initials show instead.alt(string): Accessible name. Pass '' when the name is already written next to the avatar, so it is not read twice; a status is still read.size('xs' | 'sm' | 'md' | 'lg' | 'xl'): 24, 32, 40, 48 or 64px. xs shows one initial.shape('circle' | 'square'): Square is for teams, organisations and projects.status('online' | 'away' | 'busy' | 'offline'): A dot at the bottom end corner. Never colour alone: each has its own shape, its word is in the accessible name and in the tooltip.statusLabel(string): The word for the status, for another language or another meaning ("In a meeting").hue(AvatarHue): A fixed tint: 'lime' | 'mint' | 'aqua' | 'sky' | 'violet' | 'rose' | 'peach' | 'amber'.seed(string): What the tint is derived from. Pass a user id to keep the colour when the name changes.tooltip(boolean): Show the name and status in an AppTooltip on hover. In a row of faces, AppAvatarGroup reveals names itself.tooltipPlacement('top' | 'bottom' | 'start' | 'end'): Preferred side for the tooltip; it flips when there is no room.