Avatar
Headless image component with automatic fallback to icon or text content.
Usage
The Avatar component provides a robust image loading system with automatic fallback handling. It manages multiple image sources with priority ordering and only displays the highest-priority loaded image or fallback content.
Anatomy
<script setup lang="ts">
import { Avatar } from '@vuetify/v0'
</script>
<template>
<Avatar.Root>
<Avatar.Image />
<Avatar.Fallback />
</Avatar.Root>
<Avatar.Group>
<Avatar.Root>
<Avatar.Image />
<Avatar.Fallback />
</Avatar.Root>
<Avatar.Indicator />
</Avatar.Group>
</template>Architecture
The Avatar uses an internal selection system with mandatory: 'force' to ensure exactly one element is always visible. Images register as disabled until they load successfully.
For single-source content images with placeholder and error fallback, use Image instead. Avatar specializes in identity / profile UIs with priority-based multi-source fallback.
Loading state slot props
Avatar.Image exposes the underlying loading state from useImage via slot props. Use these for custom transitions, retry UI, or status indicators.
| Slot prop | Purpose |
|---|---|
status | Current state: 'idle' | 'loading' | 'loaded' | 'error' |
isLoaded | True when the image has loaded successfully |
isError | True when the image failed to load |
retry | Reset the image and re-attempt loading |
Priority System
When multiple images are present, the priority prop determines display order. Higher priority images are preferred when loaded:
<template>
<Avatar.Root>
<!-- Preferred when loaded -->
<Avatar.Image src="/high-res.jpg" :priority="1" />
<!-- Fallback image -->
<Avatar.Image src="/low-res.jpg" :priority="0" />
<!-- Text fallback -->
<Avatar.Fallback>JD</Avatar.Fallback>
</Avatar.Root>
</template>Examples
Accessibility
Avatar is presentational — it renders an image with a text or icon fallback and ships no interactive roles or keyboard behavior. Its accessibility surface is about naming the image and announcing group truncation:
Avatar.Imagerenders an<img>withrole="img"and forwards thealtprop as its accessible name. Passaltwith a meaningful description (for example the person’s name) for identifying avatars; passalt=""for purely decorative avatars so screen readers skip them.Avatar.Fallbackrenders the initials or icon shown when no image loads. Use readable initials so identity is still conveyed when the image is unavailable.Avatar.Grouprendersrole="group"and accepts alabel(mapped toaria-label),ariaLabelledby, andariaDescribedbyso the collection has an accessible name.Avatar.Indicator(the+Noverflow chip) rendersaria-live="polite"and a localizedaria-label("+N more", via theAvatar.indicatorLabelkey) so the hidden count is announced when it changes.Avatars hidden by
Avatar.Grouptruncation are markedaria-hidden, removing them from the accessibility tree while the group reports the remainder through the indicator.
For custom markup, use renderless mode and bind the attrs slot prop to preserve these attributes:
<template>
<Avatar.Image v-slot="{ attrs }" src="/avatar.jpg" alt="Jane Doe" renderless>
<img v-bind="attrs">
</Avatar.Image>
</template>FAQ
Avatar is for identity and profile UIs with priority-based multi-source fallback to initials or an icon. For a single-source content image with placeholder and error fallback, use Image instead.
Each Avatar.Image registers disabled until it loads; an internal selection with mandatory: 'force' keeps exactly one element visible, preferring the highest-priority loaded image and falling back to Avatar.Fallback when none load.
Set responsive on the group to opt into createOverflow; the indicator self-measures and reserves room, so the visible count adjusts to the available width.
Avatar.Image exposes the underlying useImage state via slot props — status, isLoaded, isError, and a retry method — so you can drive spinners, transitions, or a retry button.
