Component API

<user-avatar>

Open live example

Circular avatar. Shows src when it loads successfully; falls back to the
first letter of name (uppercased) if src is unset or fails to load
(e.g. an expired OAuth profile-photo URL); falls back further to a generic
person icon if name is also unset. A broken image never leaves a blank
circle.

Install

import "@f-ewald/components/user-avatar.js";

Usage

<user-avatar src="https://example.com/photo.jpg" name="Freddy" size="40"></user-avatar>

Attributes / properties

PropertyAttributeTypeDefaultDescription
srcsrcstring | nullnullImage URL to show. Falls back to initials/icon if unset or it fails to load.
namenamestring | nullnullSource string for the fallback initial (e.g. a display name or email) — first character, uppercased.
sizesizestring | number32Diameter in CSS pixels, or a preset name (xs=18, sm=24, md=32, lg=48).

Events

None.

Slots

None.

CSS custom properties

Custom property
--ui-font
--ui-font-weight-semibold
--ui-on-accent
--ui-primary