Skip to content

Avatar

Avatar component based on the Image component to display a profile picture or user initials. Supports notification badges, status indicators and complete accessibility according to W3C standards.

Usage examples

Basic Avatar

Avatar with image

vue
<template>
  <SuAvatar 
    src="https://example.com/photo.jpg"
    alt="Profile picture"
    name="John Doe"
  />
</template>

Avatar with initials

Avatar without image (initials)

vue
<template>
  <SuAvatar 
    name="Marie Dupont"
    alt="Marie Dupont's avatar"
  />
</template>

API

Props

PropTypeDefaultDescription
srcstringundefinedProfile image URL
altstringundefinedAlternative text for image
fallbackstringundefinedFallback image on error
namestringundefinedName to generate initials
size'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl''md'Avatar size
variant'circle' | 'rounded' | 'square''circle'Avatar shape
status'online' | 'offline' | 'away' | 'busy'undefinedUser status
badgestring | numberundefinedNotification badge
badgeColorstringundefinedCustom badge color
loadingbooleanfalseLoading state
clickablebooleanfalseClickable avatar

Events

EventTypeDescription
@click(event: MouseEvent) => voidEmitted on click (if clickable)
@load(event: Event) => voidEmitted when image is loaded
@error(event: Event) => voidEmitted if image fails to load

Accessibility

The Avatar component follows WCAG 2.1 AA standards with complete keyboard navigation and screen reader support.

Publié sous licence MIT.