Skip to content

Avatar

Show a profile image with a fallback when it cannot load.

Demos

Size
TM

Usage

vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'

const items = [
  { value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>

<template>
  <Accordion :items="items" />
</template>

Images and fallbacks

Supply src for a portrait and text for the fallback. The fallback also appears when the image cannot load. Set alt to identify the person, or use an empty string when adjacent text already provides their name.

TMImage
ILInitials
TMImage unavailable
vue
<AppLayout :viewport="false" scroll="page">
  <template #header>Workspace</template>
  <template #left><ProjectNavigation /></template>
  <ProjectList />
  <template #footer>2 projects</template>
</AppLayout>

Installation

Complete the shared installation. Copy Avatar.vue and index.ts into app/components/ui/avatar/.

API

Variants and defaults

PropValuesDefault
sizexs, sm, md, lg, xlsm

Props

PropTypeDefaultDescription
srcstring—Image URL.
altstring""Alt text for the image.
textstring—Fallback 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.
uiAvatarUi—CSS 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"

Events

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