navius

Avatar

An image element with a fallback for representing the user.

CT JD

Features

  • Automatic and manual control over when the image renders.
  • Falls back to custom content while the image is loading or on error.
  • Optionally delay the fallback (DelayMs) to avoid a flash on fast connections.
  • Surfaces every loading transition via OnLoadingStatusChange.

Installation

Install the brain, or copy just this primitive in with the CLI.

Anatomy

Import the parts and assemble them.

API Reference

Contains all the parts of an avatar. Renders a span.

Prop Type Default
ChildContent RenderFragment? -

The image to render. By default it only renders once it has loaded; while loading and on error it is hidden so the fallback can show. Renders an img.

Prop Type Default
Src string? -
OnLoadingStatusChange EventCallback<string> -
Data attribute Values
[data-navius-avatar-image] Present on the image

An element that renders when the image has not loaded, meaning while it is loading or on error. Renders a span.

Prop Type Default
DelayMs int 0
ChildContent RenderFragment? -
Data attribute Values
[data-navius-avatar-fallback] Present on the fallback

Accessibility

Follows the WAI image guidance. The Image part renders a native <img>, so pass an alt describing the user; the Fallback's text content is read in its place when no image loads.

Avatar is presentational and not focusable, so it exposes no keyboard interactions of its own.