Bonusway design system

Data display

Avatar

A round portrait with initials as the fallback. `name` is required precisely so there is always something to draw when there is no image.

import Avatar from '@/components/ui/Avatar';

Source: src/components/ui/Avatar.tsx

Examples

Sizes

Initials, and one name

Two initials from two words, one from a single word. Non-ASCII names work — the initial is taken from the grapheme, not the byte.

Props

<Avatar> props

PropTypeDefaultDescription
namerequiredstring——
srcstring——
size'sm' | 'md' | 'lg' | 'xl' | '2xl''md'—
fit'cover' | 'contain''cover'

rectangular marks like store logos.

fallback'initials' | 'icon''initials'

The no-photo fallback: 'initials' (default) derives up to two letters from `name` — used for store logos and reviewer avatars, where the letter still identifies the thing. 'icon' shows a generic glyph instead — for the current user's own avatar, where showing their own initials back at them adds nothing.

classNamestring''—

Accessibility

  • The initials are text, so they scale and are readable by a screen reader — an image-only avatar with no name would announce nothing.

Related:Icon

Šī lapa lieto sīkfailus

Mēs izmantojam sīkfailus, lai uzlabotu tavu pieredzi mūsu vietnē un pielāgotu saturu, ko mēs tev piedāvājam. Būtiski sīkfaili ir nepieciešami, lai mūsu pakalpojums darbotos pareizi. Ja esi priecīgs, ka mēs apkopojam informāciju, izmantojot mārketinga sīkdatnes, tad izvelies “Pieņemt visu”. Vienmēr vari mainīt minētos iestatījumus, apmeklējot sīkfailu iestatījumus.

Sīkfailu iestatījumi