Skip to content
Okaapiأوكابي
Framework for the code
Theme
Okaapi on GitHub

Chapter 09 Labels

Avatar

A person's photo, or their initials when there is no photo or it fails to load. Screen readers hear the person's name, never the file name.

Use it in Angular
import { AvatarComponent } from '@okaapi-ui/angular';

Initials and sizes

Initials are the first letter of the first and last word, so they work for Arabic names too. A broken photo falls back to initials.

H‌M M‌I
Angular
<ui-avatar name="Hatem Mohamed" size="sm" />
<ui-avatar name="Mohamed Ibrahim" />
<ui-avatar name="Ibrahim Hatem" size="lg" src="/ibrahim.jpg" />

Next to a name

When the name is written beside it, mark the avatar decorative so a screen reader says the name once.

Hatem Mohamed
Angular
<div class="flex items-center gap-3">
  <ui-avatar name="Hatem Mohamed" decorative />
  <span>Hatem Mohamed</span>
</div>

In Arabic

ح‌م م
Angular
<ui-avatar name="حاتم محمد" />

When to use something else

If you needUse
Show several people in a small spaceAvatar group
Show a status next to a person, such as onlineStatus dot
A logo or a product picture A plain img with alt text

Inputs

NameTypeDefaultWhat it does
namestring — Required. Read by screen readers and turned into the initials.
srcstring — The photo. Initials show while it is missing or broken.
size'sm' | 'md' | 'lg''md'32, 40 or 56 pixels.
decorativebooleanfalseHides it from screen readers, for when the name is on screen next to it.

Keyboard and screen readers

  • Screen readers hear the person’s name, never the file name.