Components

Avatar

An image element with a fallback for when the image fails to load.

Displays a user or entity image with graceful fallback to initials or an icon when the image is unavailable or still loading.

Anatomy

  • #image: The <img> element or full image replacement.
  • #fallback: Content shown while the image is delayed, loading, or failed.

Usage

AL BK

Examples

Custom fallback

Use #fallback to render initials or an icon with your own styles.

<template>
  <Avatar src="/avatar.jpg" alt="Jane Doe">
    <template #fallback>
      <span class="avatar-initials">JD</span>
    </template>
  </Avatar>
</template>

Delayed fallback

Prevent a flash of the fallback during fast loads.

<template>
  <Avatar src="/avatar.jpg" alt="Jane Doe" text="JD" :delay-ms="300" />
</template>

Custom image element

Use #image to render a custom element instead of a plain <img>.

<template>
  <Avatar>
    <template #image="{ src, alt }">
      <img :src="src" :alt="alt" class="avatar-img" />
    </template>
    <template #fallback>
      <span class="avatar-icon">👤</span>
    </template>
  </Avatar>
</template>

API Reference

Props

PropTypeDefaultDescription
srcstringImage URL.
altstring""Alt text for the image.
textstringFallback text (e.g. initials) when no #fallback slot is provided.
delayMsnumber0Delay in ms before showing the fallback. Prevents flash on fast loads.
asstring"span"Root element tag.
uiAvatarUiCSS class overrides.

Slots

SlotScoped propsDescription
image{ src, alt, status }The image element.
fallback{ status }Shown when image is unavailable or loading.

status is one of: "idle" · "loading" · "loaded" · "error"

Emits

EventPayloadDescription
status-change[status: AvatarImageStatus]Fired when image loading status changes.

UI Options

KeyDescription
rootThe outer container element.
imageThe image element.
fallbackThe fallback element.

Styling Hooks

UI keyCSS classData attrs
rootakaza-avatardata-akaza-status
imageakaza-avatar-image
fallbackakaza-avatar-fallbackdata-akaza-status