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.
class—string | ((state: State) => string)

CSS class applied to the element, or a function that returns a class based on the component's state.
style—StyleValue | ((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.
src—string

The image source.
referrerPolicy—string

The referrer policy for the image.
crossOrigin—string

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

CSS class applied to the element, or a function that returns a class based on the component's state.
style—StyleValue | ((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.
delay—number

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

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

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