Docs

Main site

Installation Browser support Extend config MCP server
Validation Page speed testing Responsive design
Accordion Aspect Ratio Avatar Badge Banner Bento Grid Blockquote Breadcrumbs Button Callout Card Drawer Dropdown Link Modal Navbar Navblock Pagination Popover Progress Separator Tabs Timeline Toast Tooltip
Checkbox Datepicker File upload Form field Input Label OTP Radio Range Select Textarea Toggle
Header Footer
Accordion Auth Checkbox & Radio Content Drawers Features Modals Statistics & Metrics Teams Dropdowns
Address Contact number Currency symbol Date Emirates ID Name
Close
Home Documentation Components Avatar

Avatar

A user-avatar component that renders an image when one is available and falls back to slotted content (such as initials) or a default user silhouette when it is not. Supports seven sizes, square or rounded shapes, and an optional status indicator.

Media
Status
Active
Introduced
4.0.x
View source code

Anatomy

The aegov-avatar component renders a single <div> with role="img". Its content resolves in order: an <img> when src loads successfully, otherwise the default slot (e.g. initials), otherwise a built-in user-silhouette icon. An optional status dot sits in the top-end corner.

Image showing anatomy of an avatar

Item Name Description
1 Image / fallback The <img> when src resolves, or the slotted/silhouette fallback when it does not
2 Status indicator (optional) A coloured dot in the top-end corner, shown when status is set

Options

The avatar has options for different use cases. These are considered the basic properties that are applicable to an avatar.

Appearance

Two shape tokens are available. square (default) renders the avatar with rounded corners, while rounded renders a full circle. Use rounded for personal profiles and chat-style UIs; square works well for employee directories and structured layouts.

SA

Image, initials, and default fallback

Content resolves in order: an image when src loads, the default slot when it does not (e.g. initials), or a built-in silhouette icon when there is no slot content either. A broken src falls back the same way — it never shows a broken-image icon. The component does not retry: after a load error it keeps the fallback even if src changes, so re-create the element to load a new image.

Size

The size property controls the avatar's height and width.

Token Dimensions Typical use case
xs 24px (h-6 w-6) Dense lists, inline mentions, compact tables
sm 32px (h-8 w-8) Table rows, comment threads
base 40px (h-10 w-10) Default, navigation bars, list rows
lg 48px (h-12 w-12) Profile cards, headers
xl 56px (h-14 w-14) Featured profile blocks
2xl 64px (h-16 w-16) Small profile pages
3xl 80px (h-20 w-20) Full profile pages, hero sections
<aegov-avatar size="xs" src="https://randomuser.me/api/portraits/women/71.jpg" alt="Hamda Al Nuaimi"></aegov-avatar>
<aegov-avatar size="sm" src="https://randomuser.me/api/portraits/women/71.jpg" alt="Hamda Al Nuaimi"></aegov-avatar>
<aegov-avatar size="base" src="https://randomuser.me/api/portraits/women/71.jpg" alt="Hamda Al Nuaimi"></aegov-avatar>
<aegov-avatar size="lg" src="https://randomuser.me/api/portraits/women/71.jpg" alt="Hamda Al Nuaimi"></aegov-avatar>
<aegov-avatar size="xl" src="https://randomuser.me/api/portraits/women/71.jpg" alt="Hamda Al Nuaimi"></aegov-avatar>
<aegov-avatar size="2xl" src="https://randomuser.me/api/portraits/women/71.jpg" alt="Hamda Al Nuaimi"></aegov-avatar>
<aegov-avatar size="3xl" src="https://randomuser.me/api/portraits/women/71.jpg" alt="Hamda Al Nuaimi"></aegov-avatar>

Responsive size

size can also be set per breakpoint using a responsive string — for example size="sm md:base xl:lg". Any of the seven tokens above are valid at any breakpoint. Pick a value to preview what it resolves to.

<aegov-avatar size="sm md:base xl:lg" src="https://randomuser.me/api/portraits/women/75.jpg" alt="Latifa Al Shamsi" appearance="rounded"></aegov-avatar>

Status indicator

Set status to render a coloured dot in the top-end corner. Five status values are supported, each with its own colour. status="true" is shorthand for online; status="false" (the default) hides the indicator entirely.

<aegov-avatar src="https://randomuser.me/api/portraits/men/32.jpg" alt="Mohammed Al Blooshi" appearance="rounded" status="online"></aegov-avatar>
<aegov-avatar src="https://randomuser.me/api/portraits/men/32.jpg" alt="Mohammed Al Blooshi" appearance="rounded" status="away"></aegov-avatar>
<aegov-avatar src="https://randomuser.me/api/portraits/men/32.jpg" alt="Mohammed Al Blooshi" appearance="rounded" status="busy"></aegov-avatar>
<aegov-avatar src="https://randomuser.me/api/portraits/men/32.jpg" alt="Mohammed Al Blooshi" appearance="rounded" status="unavailable"></aegov-avatar>
<aegov-avatar src="https://randomuser.me/api/portraits/men/32.jpg" alt="Mohammed Al Blooshi" appearance="rounded" status="offline"></aegov-avatar>

Avatar group

The aegov-avatar-group component wraps one or more aegov-avatar children, syncing a shared size and forcing every child to appearance="rounded". variant="default" spaces the avatars apart; variant="compact" overlaps them like a stack of stickers. Set more-count to render a trailing "+N" button.

Click the "12+" button above ↑

<!-- Default: spaced -->
<aegov-avatar-group variant="default" size="lg">
  <aegov-avatar src="https://randomuser.me/api/portraits/men/71.jpg" alt="Ahmed Al Kaabi"></aegov-avatar>
  <aegov-avatar src="https://randomuser.me/api/portraits/women/60.jpg" alt="Sara Al Kaabi"></aegov-avatar>
  <aegov-avatar src="https://randomuser.me/api/portraits/women/81.jpg" alt="Reem Al Falasi"></aegov-avatar>
</aegov-avatar-group>

<!-- Compact: overlapping, with a "+N more" indicator -->
<aegov-avatar-group id="team" variant="compact" size="lg" more-count="12">
  <aegov-avatar src="https://randomuser.me/api/portraits/men/20.jpg" alt="Khalid Al Mansoori"></aegov-avatar>
  <aegov-avatar src="https://randomuser.me/api/portraits/women/52.jpg" alt="Fatima Al Zaabi"></aegov-avatar>
  <aegov-avatar src="https://randomuser.me/api/portraits/men/60.jpg" alt="Yousef Al Suwaidi"></aegov-avatar>
</aegov-avatar-group>

<script>
  document.querySelector('#team')
    .addEventListener('aegovAvatarGroupMore', () => {
      console.log('User wants to see all members');
    });
</script>

RTL support

The avatar itself is square or circular and direction-neutral — it renders identically in dir="ltr" and dir="rtl". The status indicator's position is fixed relative to the avatar using logical properties, so it stays on the top inline-end side (which mirrors to the upper-left) regardless of direction. Surrounding layout, like a profile row, flips automatically under dir="rtl".

فاطمة الزعابي
مديرة الخدمات الرقمية — هيئة تنظيم الاتصالات والحكومة الرقمية
<div dir="rtl">
  <aegov-avatar src="https://randomuser.me/api/portraits/women/52.jpg" alt="فاطمة الزعابي" size="lg" appearance="rounded" status="online"></aegov-avatar>
  <div>
    <strong>فاطمة الزعابي</strong>
    <div>مديرة الخدمات الرقمية — هيئة تنظيم الاتصالات والحكومة الرقمية</div>
  </div>
</div>

Common uses

A common use for an avatar is a profile row next to a name and title, or a cluster of avatars representing a team.

Khalid Al Mansoori
Director, Digital Services

Profile row

Pair a lg or larger avatar with the person's name and role. A status value here doubles as a live presence indicator next to their identity.

Smart City roadmap

Cross-ministry team delivering the UAE Digital Government Strategy.

Team cluster

A compact avatar group inside a card is a quick way to show who is involved without listing every name — pair it with more-count once the team grows past a handful of members.

Usage

Here is the recommended usage of an avatar on any website or application. These are recommended usage guides, however the developer must use the best practices of web and application development to accurately use this component.

Always provide a real alt

The avatar's entire accessible name comes from alt. A missing or generic alt makes the avatar meaningless to screen reader users, even if it looks fine visually.

Match appearance to context

Use rounded for personal profiles and chat-style UIs; use square for employee directories and structured, tabular layouts. Keep the choice consistent within a given context.

Cap visible avatars and use more-count for the rest

Beyond 4–5 overlapping avatars, individual images become hard to distinguish. Show a handful, then push the remainder into the +N indicator instead of rendering every member.

Use a source photo that's already cropped square, centred on the face

src renders as a real <img> with object-fit: cover inside a fixed square or circular frame — a non-square photo gets cropped to fill it, which can cut off part of the subject unpredictably. Crop to a 1:1 aspect ratio before uploading, per the UAE Design System's approved image ratios.

Do not rely on initials alone to convey identity

Initials are a visual fallback, not an accessible label. Always pair them with a correct alt — assistive technology never reads the slotted initials text.

Do not set your own aria-label on the avatar to describe status

The component already computes a label that includes the status (e.g. "Fatima, status: online"). A host-level aria-label never reaches the role="img" container that carries that label, so it is simply not announced — put the name in alt and let the component add the status.

Do not treat the avatar as clickable on its own

aegov-avatar is not focusable. If it needs to open a profile menu or navigate somewhere, wrap it in a real <a> or <button> and put the label there.

API reference

The following are the properties and references of an avatar

aegov-avatar default properties

AttributeDescriptionTypeDefault

field-id

DOM id reflected onto the inner avatar <div>. Auto-generated if omitted.

string

auto-generated

src

Image source URL.

string

undefined

alt

Alternative text for the image. Used to build the host aria-label — required for accessibility.

string

undefined

appearance

Shape — square (rounded corners) or rounded (circle).

square | rounded

square

size

Size token. Accepts a single token or a Tailwind-style responsive string.

xs | sm | base | lg | xl | 2xl | 3xl

base

status

Status indicator. Set to a status string to show it, or false to hide it. true is shorthand for online.

online | offline | away | unavailable | busy | boolean

false

aegov-avatar-group default properties

AttributeDescriptionTypeDefault

variant

Layout — default (spaced) or compact (overlapping).

default | compact

default

size

Size enforced on every child avatar. Overrides any size set on the children directly. Accepts a single token or a Tailwind-style responsive string, like size on the avatar.

xs | sm | base | lg | xl | 2xl | 3xl

base

more-count

When greater than zero, renders a trailing +N button.

number

0

more-text

Custom visible label for the more indicator. Defaults to "{moreCount}+". The button's accessible name stays the generated "Show {N} more users" either way.

string

undefined

aegov-avatar-group always overrides its children's appearance to rounded and syncs its own size onto every child — individual size/appearance set directly on a child avatar is overwritten on the next render. Avatars appended after load are not synced until the group re-renders (for example when one of its props changes), so give dynamically added avatars the same size and appearance="rounded" yourself.

Events

EventsDescriptionComponentDetail

aegovAvatarGroupMore

Fired when the trailing +N button is clicked.

aegov-avatar-group

void

Slots

ComponentDescriptionSlot

aegov-avatar

Fallback content rendered when no src is set or the image fails to load (e.g. initials).

(default)

aegov-avatar-group

Place one or more aegov-avatar children here.

(default)

Pass-through attributes

AttributeNotesForwards to

aria-*, data-*

Forwarded only while an image is rendered, together with the native image attributes below — they land on the inner <img>, which is aria-hidden. They are never copied onto the role="img" container, so an aria-label on the host does not change the avatar's accessible name; use alt for that.

inner <img>

loading, crossorigin, referrerpolicy, srcset

Native image attributes, forwarded only when an image is rendered.

inner <img>

sizes

How wide the image renders at each breakpoint, for width-descriptor (w) srcset candidates. Auto-computed from size when srcset is set and sizes is not provided explicitly — pass your own sizes to override it.

inner <img>

aria-*, data-*

Not forwarded — the group renders in the light DOM with its own built-in aria-label ("Avatar group", or "مجموعة الصور الرمزية" in RTL); a host-level aria-label has no effect. Set attributes directly on each child <aegov-avatar> instead.

aegov-avatar-group

Notes

The following notes are applicable of this component.

Built-in accessibility

  • The aegov-avatar root <div> carries role="img" and an aria-label built from alt (or "User avatar" — "الصورة الرمزية للمستخدم" in RTL — when alt is omitted). This is the only label assistive technology reads — child elements add no further announcement.
  • The inner <img> is given alt="" and aria-hidden="true" — it is presentation-only, since the meaningful label already lives on the role="img" container.
  • When status is set, it is folded directly into the container's aria-label rather than labelling the indicator separately — for example "Fatima Al Rashidi, status: online". Arabic status strings are translated built-in (online → متصل, offline → غير متصل, away → بعيد, unavailable → غير متاح, busy → مشغول).
  • The status indicator <span> itself is aria-hidden="true" — it is a colour dot for sighted users; the meaning is already in the container's label.
  • The fallback silhouette SVG is aria-hidden="true", so nothing extra is announced when no image or slot content is provided.
  • When an image fails to load, the component silently falls back to the slot / silhouette path — broken-image icons never appear.
  • aegov-avatar-group's container has role="group" and aria-label="Avatar group" ("مجموعة الصور الرمزية" in RTL), so screen readers announce the cluster as a single unit. Each child avatar keeps its own role="img" label underneath.
  • The +N more indicator is a real <button type="button">, keyboard-focusable, with aria-label="Show {N} more users" (translated automatically in RTL).

Developer responsibility

The following is required for a developer to add additionally or pay attention to regarding this component.

  • Always provide a meaningful alt when the avatar represents a real user. The fallback "User avatar" string is rarely useful in context.
  • Initials or custom slot content are visual only — assistive technology reads the container's aria-label, not the slot text. Ensure alt matches the user's actual name.
  • The avatar itself is not focusable. If it needs to be interactive (e.g. opens a profile menu), wrap it in a real <a> or <button> and label that wrapper.
  • Do not try to describe status with your own aria-label on <aegov-avatar> — the component's computed label already appends the status, and a host-level aria-label never reaches the role="img" container, so it is not announced. Put only the person's name in alt.
  • Provide a meaningful alt on every child inside an aegov-avatar-group — the group's own container label ("Avatar group") is not enough to identify individual people.
  • aegov-avatar-group has no shadow root and does not expose a prop to override its internal "Avatar group" label — a host-level aria-label is simply not read. Keep this in mind if a custom group label is ever required.

Additional notes

  • status="false" (the default) renders no indicator at all — there is no dedicated "no status" dot.
  • The inner elements carry part="avatar", part="image" and part="status", but the avatar renders in the light DOM, so aegov-avatar::part(…) does not match. Target aegov-avatar [part="image"] or the inner classes (.aegov-avatar, .avatar-image, .avatar-indicator) instead.
  • The status indicator's position is fixed to the top-end corner of the avatar (upper-right in LTR, upper-left in RTL) via CSS logical properties — there is no prop to reposition it.
  • Avoid placing too many avatars in a compact group — the overlapping arrangement makes individual avatars harder to identify. Use more-count to move the long tail into a dedicated list instead.
  • Tab moves focus to the group's +N button when present; Enter/Space activates it and emits aegovAvatarGroupMore.