Avatar
A person or an account: their picture, or initials while it loads, when it fails or when there is none.
- Domaine
- Identité et personnes
- Niveau de support
- Taille
- 3.1 kB gzip, budget 5.5 kB
- Qui l'utilise
- 10 fichiers des produits et sites en production l'importent (Verikora : 1, Folioviv : 2, Sovkora : 2, krizaka.com : 1) Compté dans l'inventaire daté du 2026-11-23.
import { Avatar } from "@krizaka/ui/avatar";Web et mobile — le même composant pour React et React Native. Stable : son API ne change qu’à une version majeure.
Pourquoi il est là. Used by Sovkora, Verikora, Folioviv, krizaka.com.
Quand l’utiliser
- Next to a name: comments, creators, members, the signed-in account in a header.
Avatar.Groupto show who takes part (followers, collaborators) in little space.
Quand ne pas l’utiliser
- For a product, a video or a place: use an image in a card.À la place : Card
- As the only way to say who someone is: show their name too, or give the avatar an
alt.
Installation
Installer
npm install @krizaka/ui @krizaka/tailwind @krizaka/tokens tailwindcssStyles
@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";Importer
import { Avatar } from "@krizaka/ui/avatar";Exemples
With an image
A picture named by alt, with initials as fallback.
Default pictures
No photo: defaultAvatar={{ brand, seed }} — the brand's gradient and a silhouette, one of six tones per person.
Fallback
No image: the initials.
Sizes
xs, sm, md (default), lg, xl.
Group
Avatar.Group with max: the others become +n.
Props
Avatar
Avatar (an image with a fallback) and Avatar.Group.
| Prop | Type | Défaut | Description |
|---|---|---|---|
alt | string | — | The image's text alternative (the person's name); empty when a visible name sits next to the avatar. |
defaultAvatar | DefaultAvatar | — | The Krizaka default picture when the person has no photo (or it fails): their brand's gradient and a silhouette,
one of six tones from seed — defaultAvatar={{ brand: "sovkora", seed: user.id }}. fallbackSrc wins over it. |
fallback | ReactNode | — | Shown while the image loads, when it fails or when there is none: initials, an icon. |
fallbackSrc | string | — | The picture to show instead when src is missing or fails to load (an image URL). The fallback still covers its own loading. |
size | AvatarSize | md | xs · sm · md · lg · xl. |
src | string | null | — | The image's URL; null or nothing shows the fallback. |
AvatarGroup
Overlapping avatars; past max, a +n avatar counts the rest.
| Prop | Type | Défaut | Description |
|---|---|---|---|
max | number | — | How many avatars are shown; the rest becomes a +n avatar. |
size | AvatarSize | — | The size of the +n avatar (match the avatars of the group). |
AvatarRoot
| Prop | Type | Défaut | Description |
|---|---|---|---|
alt | string | — | The image's text alternative (the person's name); empty when a visible name sits next to the avatar. |
defaultAvatar | DefaultAvatar | — | The Krizaka default picture when the person has no photo (or it fails): their brand's gradient and a silhouette,
one of six tones from seed — defaultAvatar={{ brand: "sovkora", seed: user.id }}. fallbackSrc wins over it. |
fallback | ReactNode | — | Shown while the image loads, when it fails or when there is none: initials, an icon. |
fallbackSrc | string | — | The picture to show instead when src is missing or fails to load (an image URL). The fallback still covers its own loading. |
size | AvatarSize | md | xs · sm · md · lg · xl. |
src | string | null | — | The image's URL; null or nothing shows the fallback. |
Accessibilité
- With
alt, the picture is an image named by it; withoutalt, it is decorative — put the name in the text next to it. - The fallback initials are shown, not announced, when an
altnames the person.
Bonnes pratiques
- Always pass a
fallback(initials) on the web: images fail, and the layout should not jump. - A profile can lack a photo: pass
defaultAvatar={{ brand, seed: user.id }}and the person gets the product's own default picture (a silhouette on the brand's gradient, one of six tones, always the same for the same id) instead of an empty circle. It also replaces a photo that fails to load.fallbackSrcis the same for your own image;kind: "plain"is the gradient alone, for initials. defaultAvatar.kindis what the picture is of:person(default, a silhouette),folder,organisationorshop(a glyph on the gradient, drawn in the page, never a person). A folder, a company or a shop never gets a silhouette. The central sets of those kinds, and the founder's illustrated people and banners, are in the Krizaka org JSON (defaultsof@krizaka/org): an app lists and picks them from there, it never bundles or hard-codes a default media URL.- The default pictures are generated from the code (
defaultAvatarSvg) and served by the Krizaka CDN (defaultAvatarUrl, 256 and 512 px WebP, SVG): a product never draws its own. - Use one size per list:
smin dense lists,mdby default,lg/xlon a profile. - In a group, set
maxso a long list ends with+ninstead of overflowing.
Composants liés
Générée depuis le code de @krizaka/ui 5.3.4 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub