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:
import '@astryx-vue/themes/neutral.css'Component usage:
<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
| Element | Description |
|---|---|
| Photo | The profile image, loaded from the src URL. Shown when available. |
| Initials | The 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 icon | A generic person silhouette. Shown when there is no photo or name. |
| Status dot | A 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 #
| Guidance | Practice |
|---|---|
| Recommended | Always provide name for fallback text and accessible labeling. |
| Recommended | Use consistent avatar sizes in lists, comments, or chat messages. |
| Recommended | Use AvatarStatusDot inside the status slot to indicate presence or status. |
| Recommended | When the avatar acts as a link or button, provide a meaningful accessible name via alt or name. |
| Don't | Use avatars as a replacement for user names. Pair avatars with a name or label. |
| Don't | Use 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 Demonstrates the avatar fallback chain: primary image, fallback image, initials, then default icon.
Avatar — Initials
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.
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




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



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




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



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.