Avatar
An image element with a fallback for when the image fails to load.
Avatar displays an image and falls back to initials or an icon while loading or after an error.
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.
vue
@layer akaza-reset;
@import "tailwindcss";
@import "akaza-ui/dist/akaza-ui.css";
Delayed fallback
Prevent a flash of the fallback during fast loads.
vue
<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>.
vue
<Button
:ui="{
root: 'rounded-md bg-black px-3 py-2 text-white',
spinner: 'size-4 animate-spin',
}"
>
Save
</Button>
API Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
src | string | — | Image URL. |
alt | string | "" | Alt text for the image. |
text | string | — | Fallback text (e.g. initials) when no #fallback slot is provided. |
delayMs | number | 0 | Delay in ms before showing the fallback. Prevents flash on fast loads. |
as | string | "span" | Root element tag. |
ui | AvatarUi | — | CSS class overrides. |
Slots
| Slot | Scoped props | Description |
|---|---|---|
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
| Event | Payload | Description |
|---|---|---|
status-change | [status: AvatarImageStatus] | Fired when image loading status changes. |
UI Options
| Key | Description |
|---|---|
root | The outer container element. |
image | The image element. |
fallback | The fallback element. |
Styling Hooks
| UI key | CSS class | Data attrs |
|---|---|---|
root | akaza-avatar | data-akaza-status |
image | akaza-avatar-image | — |
fallback | akaza-avatar-fallback | data-akaza-status |