Avatar
Images, icons, initials and groups of participants with text adjustment, fallback and adaptive sizes.
When to use
An Avatar identifies a user, team, or entity with an image, icon, or initials. AvatarGroup joins members and shows hidden elements via +N. Notifications next to the avatar are added with a composition with Badge.
Contents and dimensions of the avatar
Content priority: src, then icon, then children. The string src creates a managed image; snippet allows you to pass your own markup. shape selects circle/square. size accepts small/medium/large, a number in pixels, or a map of breakpoint sizes.
| Script | Property | Example |
|---|---|---|
| Select geometry | size, shape |
Size and shape |
| Show photo, badge or initials | src, icon, children |
Types of content |
| Fit long initials | gap |
Text selection |
| React to Window Width | responsive size |
Adaptability |
| Handle failed download | onError |
Fallback |
Text is automatically reduced within an unchanged container. gap leaves space on the sides of the text. The size map depends on the viewport; CSS defaults are used before mount, so the server does not know the size of the client window.
For string src, alt, srcSet, crossOrigin and draggable are available. If there is an error, Avatar shows an icon or text; onError with the result false cancels the fallback. Changing src starts a new attempt. If src is snippet, the image and its events are entirely owned by the application.
Group and limit of participants
AvatarGroup accepts items with a unique key and full label. label is used to identify the participant, text is used for initials. General size/shape applies to the group; a separate item can set its own Avatar settings.
max.count limits the number of visible participants, and the +N indicator is added separately. Zero disables the limit. If you need a total limit along with an indicator, the application reserves one place when overflowing, as in limit example.
max.style designs the indicator. max.popover specifies supported Popover properties; content replaces the list of hidden participants, title is the title. Managed open requires onOpenChange. By default, the contents of such a Popover are deleted after hiding.
Signatures and design
Photos need a meaningful alt if the name is not listed next to it. The decorative avatar next to the full name should not duplicate it for the screen reader. Avatar remains span: onclick itself does not add a button keyboard. To open your profile, use the available button or link.
ConfigProvider.avatar sets the class/style for avatars; record of a nested provider replaces the parent one. The group root does not automatically inherit this class/style. Avatar design tokens control the size, font, and overlap of the group. bind:nativeElement provides the native node after the mount.
A non-empty Avatar local prefixCls takes precedence over ConfigProvider.prefixCls. The empty string and undefined inherit a common prefix with the suffix -avatar, defaulting to ant-avatar. AvatarGroup uses the same basic prefix and adds -group; Members' Avatar prefixes are resolved separately, so the group's local prefix does not rename members. Example of a common prefix shows the group next to an independent standard avatar.
Examples
Sizes and shapes
Three named sizes, a numeric size and two shapes.
<script lang="ts">
import { Avatar, Flex } from '@woodger/antd';
</script>
{#snippet user()}<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
aria-hidden="true"
><circle
cx="12"
cy="8"
r="4"
/><path
d="M4 22v-2a8 8 0 0 1 16 0v2"
/></svg>{/snippet}
<Flex vertical gap={16}>
{#each ['circle', 'square'] as shape}
<Flex align="center" wrap gap={16}>
{#each [64, 'large', 'medium', 'small', 16] as size}
<Avatar
shape={shape === 'circle' ? 'circle' : 'square'}
size={typeof size === 'number'
? size
: size === 'large' ? 'large' : size === 'small' ? 'small' : 'medium'}
icon={user}
alt={("User, " + String((shape)) + ", " + String((size)) + "")}
/>
{/each}
</Flex>
{/each}
</Flex>
Image, icon and text
src takes precedence over icon and initials; the color is set by the style.
<script lang="ts">
import { Avatar, Flex } from '@woodger/antd';
const portrait =
`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" fill="#d3f0de"/><circle cx="32" cy="24" r="12" fill="#23734a"/><path d="M8 64a24 24 0 0 1 48 0" fill="#23734a"/></svg>')}`;
</script>
{#snippet user()}<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
aria-hidden="true"
><circle
cx="12"
cy="8"
r="4"
/><path
d="M4 22v-2a8 8 0 0 1 16 0v2"
/></svg>{/snippet}
{#snippet image()}<img src={portrait} alt={("Portrait in own img")} />{/snippet}
<Flex align="center" wrap gap={16}>
<Avatar icon={user} alt={("User icon")} />
<Avatar alt={("Anna")}>{("A")}</Avatar>
<Avatar alt={("User")}>USER</Avatar>
<Avatar src={portrait} alt={("Portrait")} />
<Avatar src={image} />
<Avatar
alt={("Vera")}
style="
color: #873800;
background: #ffe7ba;
"
>{("B")}</Avatar>
<Avatar icon={user} alt={("Member")} style="background:#23734a" />
</Flex>
Indentation on each side: 4px.
Automatic text size
Change initials and gap: long line shrinks inside unchanged avatar.
<script lang="ts">
import { Avatar, Button, Flex } from '@woodger/antd';
const names = ["A", "Anna", 'USER', "Long name"];
let index = $state(0);
let gap = $state(4);
</script>
<Flex align="center" wrap gap={16}>
<Avatar
id="avatar-autosize"
size={40}
{gap}
alt={(names[index])}
style="background:#d46b08"
>{(names[index])}</Avatar>
<Button
onclick={() => { index = (index + 1) % names.length; }}
>{("Change text")}</Button>
<Button onclick={() => { gap = gap === 4 ? 8 : 4; }}>{("Change gap")}</Button>
</Flex>
<p>{("Indentation on each side: ")}{gap}px.</p>
Avatar with counter
Number of notifications and a dot next to the avatar.
<script lang="ts">
import { Avatar, Badge, Flex } from '@woodger/antd';
</script>
<Flex align="center" wrap gap={32}>
<Badge count={5}>
<Avatar shape="square" alt={("Anna, 5 notifications")}>
{("AN")}
</Avatar>
</Badge>
<Badge dot>
<Avatar shape="square" alt={("Vera, there are updates")}>
{("Sun")}
</Avatar>
</Badge>
</Flex>
Group of avatars
Group by items; the +N button reveals the names of hidden participants.
<script lang="ts">
import { AvatarGroup, Flex, type AvatarGroupItem } from '@woodger/antd';
const items: AvatarGroupItem[] = [
{ key: 'anna', label: "Anna Novikova", text: "AN", style: 'background:#23734a' },
{ key: 'vera', label: "Vera Smirnova", text: "Sun", style: 'background:#ad4e00' },
{ key: 'dmitry', label: "Dmitry Orlov", text: "TO", style: 'background:#722ed1' },
{ key: 'elena', label: "Elena Sokolova", text: "EU" }
];
</script>
<Flex vertical gap={24}>
<AvatarGroup items={(items)} aria-label={("All participants")} />
<AvatarGroup items={(items)} aria-label={("Team with limit")} max={{
count: 2,
style: `
color: #873800;
background: #ffe7ba;
`,
popover: { trigger: 'click', placement: 'bottom' }
}} />
<AvatarGroup items={(items)} size="large" shape="square" aria-label={("Large group")} max={{
count: 2
}} />
</Flex>
Total limit: 3. max.count: 2.
Limit with indicator
As in the official example, the application reserves one place under +N. max.count itself counts the participants.
<script lang="ts">
import { AvatarGroup, Checkbox, Flex } from '@woodger/antd';
let includeOverflow = $state(true);
const total = 3;
const items = [
{ key: 1, label: "Anna", text: "A" },
{ key: 2, label: "Vera", text: "B" },
{ key: 3, label: "Dmitry", text: "D" },
{ key: 4, label: "Elena", text: "E" }
];
const count = $derived(
includeOverflow && items.length > total
? total - 1
: total
);
</script>
<Flex vertical gap={16}>
<Checkbox bind:checked={includeOverflow}>{("Count +N in the total limit")}</Checkbox>
<AvatarGroup items={(items)} max={{ count }} aria-label={("Limit with indicator")} />
</Flex>
<p>{("Total limit: ")}{(total)}. max.count: {count}.</p>
xs: 24 · sm: 32 · md: 40 · lg: 64 · xl: 80 · xxl: 100 px.
Adaptive size
The size is selected by the width of the viewport, and not by the width of the card. CSS defaults are used before mount.
<script lang="ts">
import { Avatar } from '@woodger/antd';
</script>
<Avatar id="avatar-responsive" alt={("Adaptive user")} size={{
xs: 24,
sm: 32,
md: 40,
lg: 64,
xl: 80,
xxl: 100
}} style="background:#23734a">{("AN")}</Avatar>
<p>xs: 24 · sm: 32 · md: 40 · lg: 64 · xl: 80 · xxl: 100 px.</p>
Errors: 0.
Image error
The invalid image is replaced with initials; onError returns false to cancel fallback.
<script lang="ts">
import { Avatar, Button, Checkbox, Flex } from '@woodger/antd';
let broken = $state(false);
let cancel = $state(false);
let errors = $state(0);
const good =
`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" fill="#23734a"/></svg>')}`;
</script>
<Flex align="center" wrap gap={16}>
<Avatar id="avatar-fallback" alt={("Anna Novikova")} src={broken
? 'data:image/png;base64,YmFk'
: good} onError={() => {
errors++;
return cancel ? false : undefined;
}}>{("AN")}</Avatar>
<Button onclick={() => { broken = !broken; }}>{(broken ? "Restore image" : "Damage the image")}</Button>
<Checkbox bind:checked={cancel}>{("Cancel fallback")}</Checkbox>
</Flex>
<p
role="status"
aria-label={("Avatar loading errors")}
>{("Errors: ")}{errors}.</p>
Local settings and tokens
ConfigProvider.avatar sets the styles, and theme.components.Avatar sets the group sizes and overlap.
<script lang="ts">
import { Avatar, AvatarGroup, ConfigProvider, Flex } from '@woodger/antd';
</script>
<ConfigProvider avatar={{ style: 'background:#23734a' }} theme={{
components: {
Avatar: {
containerSize: 44,
textFontSize: 16,
groupOverlapping: -12
}
}
}}>
<Flex align="center" wrap gap={24}>
<Avatar
id="avatar-token-size"
alt={("Local topic")}
>{("AN")}</Avatar>
<AvatarGroup items={([{ key: 1, label: "Anna", text: "A" }, {
key: 2,
label: "Vera",
text: "B"
}])} />
</Flex>
</ConfigProvider>
Image errors in preview: 0.
Project participants
- 3 Count: 3 Анна Новикова
Developer. Unread: 3.
- Дмитрий Орлов
Designer. Unread: 0.
- 1 Count: 1 Вера Смирнова
Tester. Unread: 1.
Project participants
Saved example: avatar settings, notifications and profile in Drawer.
<script lang="ts">
import {
Avatar,
Badge,
Button,
Checkbox,
Drawer,
Input,
InputNumber,
Select,
type AvatarShape
} from '@woodger/antd';
import {
avatarPictureSource,
createAvatarExample,
type AvatarPicture
} from './avatar-example.model.svelte';
const model = createAvatarExample();
let picture = $state<AvatarPicture | 'icon'>('initials');
let shape = $state<AvatarShape>('circle');
let size = $state<'inherit' | 'custom' | 'small' | 'medium' | 'large'>('medium');
let customSize = $state<number | null>(48);
let gap = $state<number | null>(4);
let letters = $state<string | undefined>(("AN"));
let name = $state<string | undefined>(("Anna Novikova"));
let preventFallback = $state(false);
let errors = $state(0);
let open = $state(false);
let person = $derived(model.selected);
function show(key: string) { if (model.select(key)) open = true; }
function reset() {
open = false;
model.reset();
}
</script>
<style>
.controls {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 16px;
min-width: 0;
}
.fields { align-items: flex-end; }
.field, .wide {
display: flex;
flex-direction: column;
}
.fields > :global(.ant-checkbox-wrapper) { align-self: center; }
.field {
width: 160px;
max-width: 100%;
}
.field label {
display: block;
margin-bottom: 8px;
}
.wide {
width: 250px;
max-width: 100%;
}
.preview {
display: flex;
align-items: center;
justify-content: center;
min-height: 160px;
margin-block: 24px;
padding: 16px;
border: 1px solid var(--ant-color-border-secondary);
border-radius: var(--ant-border-radius-lg);
}
.summary { color: var(--ant-color-text-secondary); }
.people {
display: grid;
gap: 16px;
padding: 0;
list-style: none;
}
.person {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 16px;
padding: 16px;
border: 1px solid var(--ant-color-border-secondary);
border-radius: var(--ant-border-radius-lg);
min-width: 0;
}
.details {
flex: 1 1 180px;
min-width: 0;
overflow-wrap: anywhere;
}
.details p {
margin: 4px 0 0;
color: var(--ant-color-text-secondary);
}
.profile {
display: flex;
align-items: center;
gap: 16px;
min-width: 0;
margin-block-end: 24px;
}
.profile h3 {
margin-block: 0 8px;
font-size: var(--ant-font-size-lg);
}
.profile p { margin-block: 0; }
.controls :global(.ant-btn),
.person :global(.ant-btn) {
max-width: 100%;
height: auto;
min-height: var(--ant-control-height);
white-space: normal;
}
.controls :global(.ant-btn-sm),
.person :global(.ant-btn-sm) {
min-height: var(--ant-control-height-sm);
}
.controls :global(.ant-btn-lg),
.person :global(.ant-btn-lg) {
min-height: var(--ant-control-height-lg);
}
</style>
{#snippet userIcon()}<svg
viewBox="0 0 24 24"
fill="currentColor"
><circle
cx="12"
cy="7"
r="4"
/><path
d="M3 23v-2a9 9 0 0 1 18 0v2z"
/></svg>{/snippet}
<div class="controls fields"><div class="field"><Select
aria-label={("Content Avatar")}
bind:value={picture}
options={([
{ value: 'initials', label: "Initials" },
{ value: 'icon', label: "Icon" },
{ value: 'image', label: "Image" },
{ value: 'broken', label: "Image error" }
])}
/></div><div class="field"><Select
aria-label={("Avatar Form")}
bind:value={shape}
options={([{ value: 'circle', label: 'circle' }, {
value: 'square',
label: 'square'
}])}
/></div><div
class="field"
><Select
aria-label={("Avatar size")}
bind:value={size}
options={(['inherit', 'small', 'medium', 'large', 'custom']
.map(value => ({ value: value as typeof size, label: value })))}
/></div><div class="field"><label
for="avatar-example-size"
>{("Avatar numerical size")}</label><InputNumber
id="avatar-example-size"
bind:value={customSize}
min={8}
max={128}
disabled={size !== 'custom'}
/></div><div
class="field"
><label
for="avatar-example-gap"
>{("Avatar text indentation")}</label><InputNumber
id="avatar-example-gap"
bind:value={gap}
min={0}
/></div><div
class="wide"
><Input
aria-label={("Text Avatar")}
bind:value={letters}
/></div><div
class="wide"
><Input
aria-label={("Name Avatar")}
bind:value={name}
/></div><Checkbox
bind:checked={preventFallback}
>{("Cancel fallback Avatar")}</Checkbox></div>
<div class="preview"><Avatar
id="showcase-avatar-preview"
src={picture === 'icon' ? undefined : avatarPictureSource(picture)}
alt={name}
{shape}
size={size === 'inherit' ? undefined : size === 'custom' ? customSize ?? undefined : size}
gap={gap ?? undefined}
icon={picture === 'icon' ? userIcon : undefined}
onError={() => {
errors++;
return preventFallback ? false : undefined;
}}
>{letters}</Avatar></div>
<p
id="avatar-example-errors"
class="summary"
>{("Image errors in preview: ")}{errors}.</p>
<h3>{("Project participants")}</h3>
<ul
class="people"
aria-label={("Members Avatar")}
>
{#each model.participants as participant (participant.key)}
<li
class="person"
><Badge
count={participant.unread}
><Avatar
src={avatarPictureSource(participant.picture)}
aria-hidden
>{(participant.initials)}</Avatar></Badge><div
class="details"
><strong>
{participant.name}
</strong><p>{(participant.role)}{(". Unread: ")}{(participant.unread)}.</p></div><Button
onclick={() => show(participant.key)}
>{("Open profile ")}{participant.name}</Button></li>
{/each}
</ul>
<div
class="controls"
><Button
onclick={reset}
>{("Reset Avatar Members")}</Button></div>
<Drawer bind:open title={("Member Avatar Profile")}>
{#if person}<div class="profile"><Avatar
id="showcase-avatar-profile"
src={avatarPictureSource(person.picture)}
alt={person.name}
size={64}
>{(person.initials)}</Avatar><div
class="details"
><h3>{person.name}</h3><p>{(person.role)}</p></div></div><div
class="controls"
><Button
onclick={() => { if (person) model.setPicture(person.key, 'image'); }}
>{("Show participant photo")}</Button><Button
onclick={() => { if (person) model.setPicture(person.key, 'initials'); }}
>{("Show participant's initials")}</Button><Button
onclick={() => { if (person) model.setPicture(person.key, 'broken'); }}
>{("Damage participant's photo")}</Button></div><p
class="summary"
>{("Changes are saved when the profile is reopened.")}</p>{/if}
</Drawer>
Participants: 5. The limit counts participants; The +N button is added separately. Zero shows everyone.
- Anna Novikova
- Dmitry Orlov
- Vera Smirnova
- Elena Sokolova
- Igor Volkov
Team management
Saved AvatarGroup: adding, deleting, member order and limit.
<script lang="ts">
import { onDestroy, tick } from 'svelte';
import {
AvatarGroup,
Button,
Input,
InputNumber,
Select,
type AvatarShape
} from '@woodger/antd';
import { createAvatarGroupExample } from './avatar-group-example.model.svelte';
const model = createAvatarGroupExample();
let limit = $state<number | null>(3);
let size = $state<'inherit' | 'custom' | 'small' | 'medium' | 'large'>('medium');
let numericSize = $state<number | null>(48);
let shape = $state<AvatarShape>('circle');
let name = $state<string | undefined>('');
let error = $state('');
let list = $state<HTMLUListElement>();
let nameContainer = $state<HTMLDivElement>();
let active = true;
let action = 0;
onDestroy(() => {
active = false;
action++;
});
async function add() {
const token = ++action;
if (model.add(name ?? '')) {
name = '';
error = '';
}
else {
error = ("Enter the participant's name.");
}
await tick();
if (active && token === action) {
const input = nameContainer?.querySelector('input');
input?.focus({ preventScroll: true });
}
}
async function remove(key: number) {
const index = model.members.findIndex(member => member.key === key);
if (!model.remove(key)) {
return;
}
const next = model.members[index]?.key ?? model.members[index - 1]?.key;
const token = ++action;
await tick();
if (active && token === action) {
const nextButton = list?.querySelector<HTMLButtonElement>(`[data-member-key="${next}"]`);
const target = nextButton ?? nameContainer?.querySelector('input');
target?.focus({ preventScroll: true });
}
}
async function move(key: number, direction: -1 | 1, button: HTMLButtonElement) {
if (!model.move(key, direction)) {
return;
}
const token = ++action;
await tick();
if (active && token === action) {
const target = button.disabled
? list?.querySelector<HTMLButtonElement>(`[data-member-key="${key}"]`)
: button;
target?.focus({ preventScroll: true });
}
}
function reset() {
action++;
model.reset();
error = '';
name = '';
}
</script>
<style>
.controls {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 16px;
min-width: 0;
}
.fields { align-items: flex-end; }
.field, .name {
display: flex;
flex-direction: column;
}
.field {
width: 160px;
max-width: 100%;
}
.field label, .name label {
display: block;
margin-bottom: 8px;
}
.name {
flex: 1 1 220px;
min-width: 0;
max-width: 100%;
}
.preview {
margin-block: 24px;
padding: 24px;
min-width: 0;
border: 1px solid var(--ant-color-border-secondary);
border-radius: var(--ant-border-radius-lg);
}
.members {
padding: 0;
margin-block: 24px;
list-style: none;
}
.members li {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
padding-block: 12px;
border-bottom: 1px solid var(--ant-color-border-secondary);
}
.member-name {
flex: 1 1 220px;
min-width: 0;
overflow-wrap: anywhere;
}
.controls :global(.ant-btn),
.members :global(.ant-btn) {
height: auto;
min-height: var(--ant-control-height);
max-width: 100%;
white-space: normal;
}
.controls :global(.ant-btn-sm),
.members :global(.ant-btn-sm) {
min-height: var(--ant-control-height-sm);
}
.controls :global(.ant-btn-lg),
.members :global(.ant-btn-lg) {
min-height: var(--ant-control-height-lg);
}
.error { color: var(--ant-color-error); }
.summary { color: var(--ant-color-text-secondary); }
</style>
<div class="controls fields"><div class="field"><label for="avatar-group-example-limit">
{("AvatarGroup Limit")}
</label><InputNumber
id="avatar-group-example-limit"
bind:value={limit}
min={0}
precision={0}
/></div><div
class="field"
><Select
aria-label={("AvatarGroup size")}
bind:value={size}
options={(['inherit', 'small', 'medium', 'large', 'custom']
.map(value => ({ value: value as typeof size, label: value })))}
/></div><div class="field"><label
for="avatar-group-example-size"
>{("AvatarGroup numeric size")}</label><InputNumber
id="avatar-group-example-size"
bind:value={numericSize}
min={8}
max={96}
disabled={size !== 'custom'}
/></div><div
class="field"
><Select
aria-label={("AvatarGroup Form")}
bind:value={shape}
options={([{ value: 'circle', label: 'circle' }, {
value: 'square',
label: 'square'
}])}
/></div></div>
<div class="preview"><AvatarGroup
id="showcase-avatar-group"
items={(model.members)}
size={size === 'inherit' ? undefined : size === 'custom' ? numericSize ?? undefined : size}
{shape}
max={{ count: limit ?? undefined }}
aria-label={("Project team")}
/></div>
<p class="summary">{("Participants: ")}{(model.members.length)}{(". The limit counts participants; The +N button is added separately. Zero shows everyone.")}</p>
<div class="controls fields"><div class="name" bind:this={nameContainer}><label
for="avatar-group-example-name"
>{("New member of AvatarGroup")}</label><Input
id="avatar-group-example-name"
bind:value={name}
aria-describedby={error ? 'avatar-group-example-error' : undefined}
aria-invalid={error ? true : undefined}
onkeydown={event => {
if (event.key === 'Enter' && !event.isComposing) {
event.preventDefault();
void add();
}
}}
/></div><Button type="primary" onclick={() => { void add(); }}>
{("Add AvatarGroup member")}
</Button><Button
onclick={reset}
>{("Reset AvatarGroup command")}</Button></div>
{#if error}<p id="avatar-group-example-error" class="error">{error}</p>{/if}
<ul
bind:this={list}
class="members"
aria-label={("AvatarGroup team management")}
>{#each model.members as member, index (member.key)}<li><span
class="member-name"
>{(member.label)}</span><Button
disabled={index === 0}
aria-label={("Above " + String((member.label)) + "")}
onclick={event => { void move(member.key, -1, event.currentTarget); }}
>{("Above")}</Button><Button
disabled={index === model.members.length - 1}
aria-label={("Below " + String((member.label)) + "")}
onclick={event => { void move(member.key, 1, event.currentTarget); }}
>{("Below")}</Button><Button
aria-label={("Delete " + String((member.label)) + "")}
data-member-key={member.key}
onclick={() => { void remove(member.key); }}
>{("Delete")}</Button></li>{/each}</ul>
API
Examples are checked against the current ant.design page and the public API of the installed package. Full definitions of Props are in @woodger/antd.
| Theme | Example or limitation |
|---|---|
| Basic | Sizes and shapes. |
| Type | String src, src Snippet, icon and text. |
| Autoset Font Size | Text adjustment and gap. |
| With Badge | Number and point. |
| Avatar.Group | items, limit, Popover and forms. |
| Include overflow in max.count | Applied calculation of the +N slot, as in the wrapper of the official example. |
| Responsive Size | Size map by viewport. |
| Property | Description | Type | Default |
|---|---|---|---|
prefixCls | Full local CSS prefix for Avatar root, image, and text. The empty string and undefined inherit ConfigProvider.prefixCls; by default ant-avatar. | string | ConfigProvider + -avatar |
src | Image or own fragment with img. | string | Snippet | — |
alt | Available avatar name; The image inside is decorative. | string | — |
icon | Icon, including fallback after src error. | Snippet | — |
children | Text or initials with automatic scaling. | Snippet | — |
size | small, medium, large, number or map breakpoints. | AvatarSize | context / medium |
shape | Container shape. | circle | square | circle |
gap | Minimum text indentation on each side. | number | 4 |
srcSet | Picture options for screen density. | string | — |
onError | false leaves a damaged image. | () => boolean | void | — |
nativeElement | bind:nativeElement instead of React ref. | HTMLSpanElement | — |
AvatarGroup
items - required AvatarGroupItem list; size and shape set general values with priority to participant settings. max contains count, style and popover.
prefixCls specifies the local base class of the group to which it is added -group. Without it, including an empty line is valid ConfigProvider.prefixCls + -avatar. Avatar members resolve their prefixes independently; the local group prefix does not rename them.
Semantic DOM
Avatar renders span, image, icon wrapper or scalable string. Separate classNames/styles API; available class, style and ConfigProvider.avatar.
alt or aria-label names the root. Next to your full name, use aria-hiddento avoid repetitions. For an interactive avatar, use a real button or link: the handle on the span itself does not add a keyboard.
AvatarGroup - a named group with an overflow button. The button is accessible from the keyboard, Escape closes the Popover and returns focus.
Registration tokens
theme.components.Avatar controls group sizes, fonts and overlap; settings size of a specific avatar take precedence over the dimensions from the theme. General colors and fillets are inherited from ConfigProvider.
| Token | Purpose |
|---|---|
containerSize | Regular size. |
containerSizeLG | Large size. |
containerSizeSM | Small size. |
textFontSize | Text font. |
textFontSizeLG | Large avatar text. |
textFontSizeSM | Small avatar text. |
iconFontSize | Icon font. |
iconFontSizeLG | Large icon. |
iconFontSizeSM | Small icon. |
groupSpace | Interval of the list of hidden participants. |
groupOverlapping | Overlapping group elements. |
groupBorderColor | Color of the border of participants. |
| Token | Current value |
|---|---|
colorText | rgba(0,0,0,0.88) |
colorTextLightSolid | #fff |
colorTextPlaceholder | rgba(0,0,0,0.25) |
borderRadius | 6 |
borderRadiusLG | 8 |
borderRadiusSM | 4 |
fontFamily | -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
'Noto Color Emoji' |
fontSize | 14 |
lineHeight | 1.5714285714285714 |
lineWidth | 1 |
FAQ
Is +N included in max.count?
No. Count limits participants, the indicator is added separately. For the total limit, reserve space in the application.
How is the Svelte API different from React?
The group is exported as AvatarGroup and receives items. Content is transmitted by snippets, CSS - by strings; ref is replaced by the binding of the native node.
What happens when there is a photo error?
For string src, icon is used, then text. Returning false from onError cancels the replacement. The custom src-snippet manages this on its own.