Skip to content

Avatar

An easily stylable avatar component.

LT LT

Anatomy

Import the component and assemble its parts:

vue
<script setup>
import { AvatarFallback, AvatarImage, AvatarRoot } from 'base-ui-vue'
</script>

<template>
  <AvatarRoot>
    <AvatarImage src="" />
    <AvatarFallback>LT</AvatarFallback>
  </AvatarRoot>
</template>

API reference

Root

Displays a user's profile picture, initials, or fallback icon. Renders a <span> element.

PropDefaultType
as'span'string | Component

The element or component to use for the root node.
classstring | ((state: State) => string)

CSS class applied to the element, or a function that returns a class based on the component's state.
styleStyleValue | ((state: State) => StyleValue)

Style applied to the element, or a function that returns a style object based on the component's state.

Image

The image to be displayed in the avatar. Renders an <img> element.

PropDefaultType
as'img'string | Component

The element or component to use for the root node.
srcstring

The image source.
referrerPolicystring

The referrer policy for the image.
crossOriginstring

The cross origin attribute for the image.
classstring | ((state: State) => string)

CSS class applied to the element, or a function that returns a class based on the component's state.
styleStyleValue | ((state: State) => StyleValue)

Style applied to the element, or a function that returns a style object based on the component's state.
EmitsTypeDescription
loadingStatusChange((status: ImageLoadingStatus) => void) | undefinedCallback fired when the loading status changes.
AttributeDescription
data-starting-stylePresent when the image is animating in.
data-ending-stylePresent when the image is animating out.

Fallback

Rendered when the image fails to load or when no image is provided. Renders a <span> element.

PropDefaultType
as'span'string | Component

The element or component to use for the root node.
delaynumber

How long to wait before showing the fallback. Specified in milliseconds.
classstring | ((state: State) => string)

CSS class applied to the element, or a function that returns a class based on the component's state.
styleStyleValue | ((state: State) => StyleValue)

Style applied to the element, or a function that returns a style object based on the component's state.