Skip to content

Avatar

The Avatar component is used to represent users, entities, or teams. It can display images, abbreviated text, or serve as a container for icons.

With the Avatar List container, you can easily achieve stacked display of team members.

Basic Usage

The most common usage is to pass a src prop to display an image. When the image fails to load or is not provided, the component automatically falls back to displaying the text from the text prop.

💡 Smart Truncation: If the text contains Chinese characters, it automatically extracts the first character; if it's pure English, it takes the first three letters and capitalizes them.

vue

<TAvatar src="/avatar.png"></TAvatar>
<TAvatar text="Zhang San"></TAvatar>
<TAvatar text="Alex" color="blue-lt"></TAvatar>
<TAvatar text="WK" color="purple-lt"></TAvatar>
<TAvatar text="Li Si" src="/404.png"></TAvatar>

Shape

The component uses a slight rounded corner by default (rounded).

You can change it to a full circle (circle) or a square (square) via the shape prop.

vue

<TAvatar src="/avatar.png" shape="rounded"></TAvatar>
<TAvatar src="/avatar.png" shape="circle"></TAvatar>
<TAvatar src="/avatar.png" shape="square"></TAvatar>

Size

We offer multiple standardized sizes from xs to xl.

Choose the size that best fits your page layout to maintain visual hierarchy.

vue

<TAvatar src="/avatar.png" size="xs"></TAvatar>
<TAvatar src="/avatar.png" size="sm"></TAvatar>
<TAvatar src="/avatar.png" size="md"></TAvatar>
<TAvatar src="/avatar.png" size="lg"></TAvatar>
<TAvatar src="/avatar.png" size="xl"></TAvatar>

Color

For text-fallback avatars, providing a distinct background color helps differentiate users.

Only -lt light variants are recommended.

vue

<TAvatar text="A" color="primary-lt"></TAvatar>
<TAvatar text="B" color="success-lt"></TAvatar>
<TAvatar text="C" color="danger-lt"></TAvatar>
<TAvatar text="D" color="yellow-lt"></TAvatar>
<TAvatar text="E" color="indigo-lt"></TAvatar>

Status & Badges

You can add a status indicator to the avatar to show a user's online/offline status, or to indicate the number of messages they have received.

Thanks to the composability of the component, simply place a TBadge component directly inside the default slot of TAvatar, and it will automatically attach to the edge of the avatar.

🌟 You can also add the avatar-brand class to images or icons to automatically stick to the edge of the avatar.

Show Code
vue

<TAvatar src="/avatar.png">
  <TBadge color="success"></TBadge>
</TAvatar>
<TAvatar text="SA">
  <TBadge color="warning"></TBadge>
</TAvatar>
<TAvatar src="/avatar.png">
  <TBadge color="danger"></TBadge>
</TAvatar>
<TAvatar shape="circle" src="/avatar.png">
  <TBadge color="danger">5</TBadge>
</TAvatar>
<TAvatar src="/avatar.png">
  <IconVip class="avatar-brand" style="color:#d63939"/>
</TAvatar>

Avatar List

When you need to display a group of related users (e.g., project members, like lists), use the TAvatarList container.

You can uniformly set size and shape on the container, and the inner avatars will inherit them automatically.

vue

<TAvatarList size="sm" shape="circle">
  <TAvatar text="Zhao" color="blue-lt"></TAvatar>
  <TAvatar text="Qian" color="azure-lt"></TAvatar>
  <TAvatar text="Sun" color="indigo-lt"></TAvatar>
  <TAvatar text="Li" color="purple-lt"></TAvatar>
</TAvatarList>

Stacked & Max

When stacked is enabled, avatars in the list overlap like playing cards — great for saving space.

Combined with the max prop, you can limit how many avatars are visible.

Excess avatars are hidden and a summary marker (e.g. +3) appears at the end.

vue

<TAvatarList stacked :max="4" size="md" shape="circle">
  <TAvatar src="/avatar.png" v-for="n in 7"></TAvatar>
</TAvatarList>

Interactive Add Button

The TAvatar component supports click event binding, so you can flexibly use it as an action button.

Placing an avatar with an icon at the end of TAvatarList makes it easy to create an "Add Member" or "Load More" interaction, seamlessly blending into the stacked list.

View Code
vue

<script setup>
  import {ref} from 'vue';
  import {IconPlus} from '@tabler/icons-vue';

  const i = ref(3); // initially 3 avatars
</script>

<template>
  <p>Click the + avatar on the right to dynamically increase the number of avatars in the list:</p>
  <TAvatarList stacked size="md" shape="circle">
    <!-- Render existing avatars -->
    <TAvatar src="/avatar.png" v-for="n in i" :key="n"></TAvatar>
    <!-- As a clickable "add" button -->
    <TAvatar text="" @click="i = i + 1" color="secondary-lt">
      <IconPlus/>
    </TAvatar>
  </TAvatarList>
</template>

API

TAvatar Props

PropDescriptionTypeDefault
srcThe image URL for the avatar.stringundefined
textFallback text when no image is available or image fails to load.string''
altNative img alt attribute, or aria-label.string'Avatar'
sizeAvatar size (if wrapped in a List, the List's size takes priority).'xxs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl''md'
shapeAvatar shape (if wrapped in a List, the List's shape takes priority).'rounded' | 'square' | 'circle''rounded'
colorBackground color for text fallback. Supports theme colors and -lt light variants.TablerColorundefined

TAvatarList Props

PropDescriptionTypeDefault
stackedEnable avatar stacking mode — avatars overlap to save space.booleanfalse
maxMaximum number of avatars to display. Excess avatars are hidden and +N is shown. Value 0 means no limit.number0
sizeUniform size for all inner avatars.'xxs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl''md'
shapeUniform shape for all inner avatars.'rounded' | 'square' | 'circle''rounded'