Skip to content

Accessibility: Full

Translations: Not Needed

Avatar

Atomic avatar element that displays either an image, initials, or a fallback icon.

Default

CM
Vue
html
<template>
  <HLAvatar id="example-avatar-default">CM</HLAvatar>
</template>

<script setup lang="ts">
  import { HLAvatar } from '@platform-ui/highrise'
</script>

All Sizes

CM
CM
CM
CM
CM
CM
CM
CM
CM
CM
CM
CM
CM
CM
CM
CM
html
<!-- Round Avatars (Default) -->
<HLAvatar size="2xl">CM</HLAvatar>
<HLAvatar size="xl">CM</HLAvatar>
<HLAvatar size="lg">CM</HLAvatar>
<HLAvatar size="md">CM</HLAvatar>
<HLAvatar size="sm">CM</HLAvatar>
<HLAvatar size="xs">CM</HLAvatar>
<HLAvatar size="2xs">CM</HLAvatar>
<HLAvatar size="3xs">CM</HLAvatar>
html
<!-- Square Avatars -->
<HLAvatar :round="false" size="2xl">CM</HLAvatar>
<HLAvatar :round="false" size="xl">CM</HLAvatar>
<HLAvatar :round="false" size="lg">CM</HLAvatar>
<HLAvatar :round="false" size="md">CM</HLAvatar>
<HLAvatar :round="false" size="sm">CM</HLAvatar>
<HLAvatar :round="false" size="xs">CM</HLAvatar>
<HLAvatar :round="false" size="2xs">CM</HLAvatar>
<HLAvatar :round="false" size="3xs">CM</HLAvatar>

Avatar with Initials

JD

AS

RJ

Vue
html
<HLAvatar id="example-avatar-initials" size="2xl" name="John Doe" />
<!-- Will automatically display "JD" -->

Avatar with Image

JD

Vue
html
<!-- Avatar with image and event handlers -->
<HLAvatar
  id="example-avatar-image"
  size="2xl"
  src="https://example.com/avatar.jpg"
  @error="handleImageError"
  @load="handleImageLoad"
  @click="handleAvatarClick"
/>

<!-- Avatar with fallback to initials if image fails -->
<HLAvatar id="example-avatar-fallback" size="2xl" src="invalid-url.jpg" name="John Doe" />

Avatar with Status Indicator

CM
ABavatar
Vue
html
<HLBadge size="2xl" dot :offset="[-10, 10]" id="example-avatar-indicator-2xl">
  <HLAvatar size="2xl">CM</HLAvatar>
</HLBadge>
<HLBadge size="sm" dot :offset="[-5, 5]">
  <HLAvatar size="sm" :round="false">CM</HLAvatar>
  <template #value>
    <img src="https://picsum.photos/seed/FeB6P/640/480" alt="avatar" />
  </template>
</HLBadge>

Event Testing

This example shows handling of the @click and @error events. Click on any avatar or try loading an invalid image to see the event log.

AS

Event Log:

No events logged yet. Try clicking the avatars above or loading an invalid image.

Imports

ts
import { HLAvatar, HLBadge } from '@platform-ui/highrise'

Ref: Badge

Props

NameTypeDefaultDescription
id *string | undefinedundefinedThe id of the element
size'2xl' | 'xl' | 'lg' | 'md' | 'sm' | 'xs' | '2xs' | '3xs''xs'The size of the avatar
objectFit'fill' | 'contain' | 'cover' | 'none' | 'scale-down''fill'Object fit property of the avatar image
roundbooleantrueWhether the avatar should be circular
srcstring | undefinedundefinedURL of the avatar image
preferredInitialsBgColorstring | undefinedundefinedCustom background color to use when displaying initials. If not provided, a color will be automatically generated based on the name
namestring | undefinedundefinedThe full name string from which initials will be derived (e.g., "John Doe" → "JD")

Emits

NameArgumentsDescription
@error() => voidTriggered when the avatar image fails to load
@click() => voidTriggered when the avatar is clicked

Slots

NameParametersDescription
default()The default content slot