On this page

Avatar

Live examples of Avatar, with the exact Vue file that renders each one.

Every example is a complete Vue file. Copy it into an app that has the registry installed, or open it in StackBlitz.

Sizes

Small in dense tables and lists, default elsewhere, large in a profile header. Without a photo, the initials show.

LTLTLT
AvatarSizes.vue
<script setup lang="ts">
import { Avatar, AvatarFallback } from '@/components/ui/avatar'

// sm in dense tables and lists, default elsewhere, lg in a profile header. Without a photo, the initials show.
</script>

<template>
  <div class="flex items-center gap-(--bh-space-200)">
    <Avatar size="sm"><AvatarFallback>LT</AvatarFallback></Avatar>
    <Avatar><AvatarFallback>LT</AvatarFallback></Avatar>
    <Avatar size="lg"><AvatarFallback>LT</AvatarFallback></Avatar>
  </div>
</template>

Status dot

The dot is 8 px at every size. The status is also written next to the name, so it does not rely on colour.

  • MNOnline
    Minh NguyenWarehouse manager · Online
  • HPAway
    Hoa PhamSales, CRM · Away
  • QLOffline
    Quang LeAccounting, ERP · Offline
AvatarStatus.vue
<script setup lang="ts">
import { Avatar, AvatarBadge, AvatarFallback } from '@/components/ui/avatar'

const people = [
  { name: 'Minh Nguyen', initials: 'MN', role: 'Warehouse manager', status: 'success', label: 'Online' },
  { name: 'Hoa Pham', initials: 'HP', role: 'Sales, CRM', status: 'warning', label: 'Away' },
  { name: 'Quang Le', initials: 'QL', role: 'Accounting, ERP', status: 'neutral', label: 'Offline' },
] as const
</script>

<template>
  <ul class="m-0 flex list-none flex-col gap-(--bh-space-150) p-0">
    <li v-for="person in people" :key="person.name" class="flex items-center gap-(--bh-space-100)">
      <Avatar>
        <AvatarFallback>{{ person.initials }}</AvatarFallback>
        <AvatarBadge :status="person.status">{{ person.label }}</AvatarBadge>
      </Avatar>
      <div class="flex flex-col">
        <span class="text-(--bh-color-text) [font:var(--bh-font-label-default)]">{{ person.name }}</span>
        <span class="text-(--bh-color-text-subtle) [font:var(--bh-font-body-small)]">{{ person.role }} · {{ person.label }}</span>
      </div>
    </li>
  </ul>
</template>

Group with a count

Overlapping avatars of the people on a record, with the rest as a count. The group has one name for screen readers.

MNHPQL
+3
6 editors
AvatarGroupCount.vue
<script setup lang="ts">
import { Avatar, AvatarFallback, AvatarGroup, AvatarGroupCount } from '@/components/ui/avatar'

const members = ['MN', 'HP', 'QL']
</script>

<template>
  <div class="flex items-center gap-(--bh-space-100)">
    <AvatarGroup role="group" aria-label="6 people can edit this connection">
      <Avatar v-for="initials in members" :key="initials" size="sm">
        <AvatarFallback>{{ initials }}</AvatarFallback>
      </Avatar>
      <AvatarGroupCount>+3</AvatarGroupCount>
    </AvatarGroup>
    <span class="text-(--bh-color-text-subtle) [font:var(--bh-font-body-default)]">6 editors</span>
  </div>
</template>