Documentation

Avatar

A person or an account: their picture, or initials while it loads, when it fails or when there is none.

Web + MobileStableAffichage de données

Web et mobile — le même composant pour React et React Native. Stable : son API ne change qu’à une version majeure.

Quand l’utiliser

  • Next to a name: comments, creators, members, the signed-in account in a header.
  • Avatar.Group to 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@beta @krizaka/tailwind@beta @krizaka/tokens@beta tailwindcss

Styles

@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.

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.

PropTypeDéfautDescription
altstring—The image's text alternative (the person's name); empty when a visible name sits next to the avatar.
fallbackReactNode—Shown while the image loads, when it fails or when there is none: initials, an icon.
sizeAvatarSizemdxs · sm · md · lg · xl.
srcstring | null—The image's URL; null or nothing shows the fallback.

AvatarGroup

Overlapping avatars; past max, a +n avatar counts the rest.

PropTypeDéfautDescription
maxnumber—How many avatars are shown; the rest becomes a +n avatar.
sizeAvatarSize—The size of the +n avatar (match the avatars of the group).

AvatarRoot

PropTypeDéfautDescription
altstring—The image's text alternative (the person's name); empty when a visible name sits next to the avatar.
fallbackReactNode—Shown while the image loads, when it fails or when there is none: initials, an icon.
sizeAvatarSizemdxs · sm · md · lg · xl.
srcstring | null—The image's URL; null or nothing shows the fallback.

Accessibilité

  • With alt, the picture is an image named by it; without alt, it is decorative — put the name in the text next to it.
  • The fallback initials are shown, not announced, when an alt names the person.

Bonnes pratiques

  • Always pass a fallback (initials) on the web: images fail, and the layout should not jump.
  • Use one size per list: sm in dense lists, md by default, lg/xl on a profile.
  • In a group, set max so a long list ends with +n instead of overflowing.

Générée depuis le code de @krizaka/ui 2.0.0-beta.6 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub

Sur cette page