Avatar

Alignment target:@astryxdesign/core v0.7.1 · Avatar

Usage #

Import the component from its dedicated entry. Structural styles are loaded automatically.

Import the theme once at your app entry:

TypeScript
import '@astryx-vue/themes/neutral.css'

Component usage:

Vue
<script setup lang="ts">
import { Avatar, AvatarStatusDot } from '@astryx-vue/core/Avatar'
</script>

<template>
  <Avatar src="/user.jpg" name="John Doe" />
  <Avatar name="Jane Smith" size="xl" />
  <Avatar src="/user.jpg" name="John Doe">
    <template #status>
      <AvatarStatusDot variant="success" />
    </template>
  </Avatar>
</template>

Anatomy

ElementDescription
PhotoThe profile image, loaded from the src URL. Shown when available.
InitialsThe first letter, digit or emoji of the first and last words of the name; punctuation is skipped. Shown when no photo is available. A name with no letters, digits or emoji shows the default icon instead.
Default iconA generic person silhouette. Shown when there is no photo or name.
Status dotA small indicator in the bottom-right corner showing availability (online, away, busy). Each variant pairs colour with a distinct shape so status does not rely on colour alone.

Best practices #

GuidancePractice
RecommendedAlways provide name for fallback text and accessible labeling.
RecommendedUse consistent avatar sizes in lists, comments, or chat messages.
RecommendedUse AvatarStatusDot inside the status slot to indicate presence or status.
RecommendedWhen the avatar acts as a link or button, provide a meaningful accessible name via alt or name.
Don'tUse avatars as a replacement for user names. Pair avatars with a name or label.
Don'tUse low-resolution images. Avatars are often clipped as circles, which magnifies blur.

Examples #

Avatar — Fallback chain

Valid src
Invalid src, valid fallbackSrc
Both invalid, has name
All invalid, no name
Open in Playground

Demonstrates the avatar fallback chain: primary image, fallback image, initials, then default icon.

Avatar — Initials

First + last
Single name
Multi-word
Prefixed
Open in Playground

Show initials instead of a photo. The avatar extracts the first and last initials from the name automatically. Use when you only have a user name.

Avatar — Interactive

Link (href)
Button (onClick)
Open in Playground

Pass href to make the avatar a link, or as to use a router link instead. A click listener without an address makes it a button. Both forms are focusable and show a focus-visible ring.

Avatar — Tooltip

Hover or focus to reveal each name
Custom tooltip text
Open in Playground

By default an avatar shows its name in a tooltip on hover and keyboard focus. Pass a string to show custom text instead, or false to turn the tooltip off.

Avatar — User card

Itai JordaanEngineering Lead
Margot SchroderProduct Designer
Daniela GimenezEngineering Manager
Open in Playground

Place an avatar next to a name and role to create a user card row. Use for comment headers, contact lists, profile sections, or anywhere you need to identify a person.

Avatar — Photo

Open in Playground

Show a profile photo at different sizes. Use when you have a user photo URL. If the image fails to load, initials are shown instead.

Avatar — Status dot

Open in Playground

Add a status dot to an avatar to show whether someone is online, away, or busy. Use in chat, messaging, or any UI where knowing availability matters.