Avatar
Genel görünümimport { Avatar, AvatarGroup, CompactAvatarGroup, FlatAvatar } from '@nili/ui';Bu, kütüphanenin kendi genel görünüm sayfası — canlı olarak render ediliyor. Üstten dili veya temayı değiştirin, o da değişir.
Boyutlar
Dokuz boyut, 80 pikselden 16’ya. name zorunludur: adı olmayan bir avatar ya etiketsiz bir görsel ya da süsleyici bir lekedir ve hangisi olduğunu yalnızca çağrı yeri bilir. Süs olduğunu belirtmek için boş bir dize verin.
import { Avatar } from "@nili/ui"
export function Example() {
return (
<>
<Avatar size="3xl" name="Ada Lovelace" />
<Avatar size="xl" name="Ada Lovelace" />
<Avatar size="md" name="Ada Lovelace" />
<Avatar size="2xs" name="Ada Lovelace" />
</>
)
}Yedekler
Görsel yoksa baş harfler name’den türetilir. Bunları initials ile geçersiz kılın, fallback ile tamamen değiştirin ya da siluet için placeholder kullanın — fotoğrafı ve baş harfe değer bir adı olmayan bir hesap.
import { Avatar } from "@nili/ui"
export function Example() {
return (
<>
{/* initials from the name */}
<Avatar name="Ada Lovelace" />
{/* explicit initials */}
<Avatar name="محمد رضایی" initials="مر" />
{/* an image, with initials behind it */}
<Avatar name="Grace Hopper" src="/avatars/grace.png" />
{/* the silhouette */}
<Avatar name="" placeholder />
</>
)
}Tonlar
Figma’da Avatar’ın renk ekseni yok — tonlar bir eklentidir ve gruplar için vardır: altı özdeş gri dairenin yığını okunmaz ve onları renklendirmek, görseller yüklenmeden ayırt etmenin en ucuz yoludur.
import { Avatar } from "@nili/ui"
export function Example() {
return (
<>
<Avatar name="Ada Lovelace" tone="soft" />
<Avatar name="Grace Hopper" tone="blue" />
<Avatar name="Radia Perlman" tone="pink" />
</>
)
}Durumlar
Üstte bir, altta bir işaret. Ona bir statusLabel verin — renkli bir noktanın erişilebilir adı yoktur. Her boyut bir işaret taşıyamaz; küçük uç, okunaksız bir benek çizmek yerine işareti düşürür.
import { Avatar, Icon } from "@nili/ui"
import { RiBuilding2Line } from "@remixicon/react"
export function Example() {
return (
<>
<Avatar name="Ada Lovelace" bottomStatus="online" statusLabel="Online" />
<Avatar name="Ada Lovelace" bottomStatus="busy" statusLabel="Busy" />
<Avatar name="Ada Lovelace" topStatus="verified" statusLabel="Verified" />
<Avatar
name="Apex Financial"
bottomStatus="company"
companyIcon={<Icon icon={RiBuilding2Line} />}
statusLabel="Company account"
/>
</>
)
}Avatar grubu
“+N” çipli bir yığın. max kaç tanesinin çizileceğini sınırlar; overflowCount, elinizdeki liste daha büyük bir kümenin yalnızca bir sayfasıyken hesaplanan kalanı geçersiz kılar.
import { AvatarGroup } from "@nili/ui"
const team = [
{ id: "a", name: "Ada Lovelace", tone: "blue" },
{ id: "b", name: "Grace Hopper", tone: "purple" },
{ id: "c", name: "Katherine Johnson", tone: "green" },
{ id: "d", name: "Radia Perlman", tone: "pink" },
]
export function Example() {
return (
<>
<AvatarGroup items={team} label="Team members" />
<AvatarGroup items={team} max={3} label="Team members" />
<AvatarGroup items={team} max={2} overflowCount={24} label="Team" />
</>
)
}Kompakt avatar grubu
Hap içinde daha yoğun bir yığın — Avatar Group’un boşluklarının fazla cömert kaldığı tablo satırları ve liste öğeleri için. Üç boyut, iki işleyiş.
import { CompactAvatarGroup } from "@nili/ui"
export function Example() {
return (
<>
<CompactAvatarGroup items={team} max={3} label="Assignees" />
<CompactAvatarGroup items={team} max={3} appearance="stroke" label="Assignees" />
</>
)
}Düz avatar
Değiştirilebilir Figma parçalarından kurulan çizimli avatar. Dizinler başa döner; yani her sayı geçerli ve belirlenimci bir seçimdir — bir kullanıcı kimliğinden kararlı bir avatar türetmek için elverişlidir.
import { FlatAvatar } from "@nili/ui"
export function Example() {
return (
<>
<FlatAvatar size="2xl" background={4} hair={2} outfit={1} label="" />
{/* derived from an id — same user, same face, every time */}
<FlatAvatar
size="xl"
background={userId % 8}
hair={userId % 6}
eye={userId % 4}
label=""
/>
</>
)
}Avatar
extends Omit< ComponentPropsWithoutRef<'div'>, 'color' | 'children' >
Varyant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| size | 3xl | 2xl | xl | lg | md | sm | xs | 2xs | 3xs | md |
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| tone | soft | yellow | blue | green | pink | purple | red | soft | Background/foreground pair for the fallback surface. |
| name* | string | — | Accessible name. Required, because an avatar with no name is either an unlabelled image or a decorative blob, and only the call site knows which. Pass `''` to mark it decorative when the person's name is already visible next to it. |
| src | string | — | |
| onImageError | () => void | — | |
| initials | string | — | Initials to show when there is no image. Derived from `name` if omitted. |
| fallback | ReactNode | — | Arbitrary fallback content — overrides `initials`. |
| topStatus | verified | pin | favorite | add | remove | notification | — | |
| bottomStatus | online | offline | busy | away | company | — | |
| companyIcon | ReactNode | — | Rendered when `bottomStatus` is `'company'`. |
| statusLabel | string | — | Accessible name for the status marker, e.g. `'Online'`. |
| placeholder | boolean | false | Figma's "Icon" style: a person silhouette on the tone colour, for accounts with no photo and no name worth initialising. |
AvatarGroup
extends Omit< ComponentPropsWithoutRef<'div'>, 'children' >
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| size | 3xl | 2xl | xl | lg | md | sm | xs | 2xs | 3xs | md | |
| items* | AvatarGroupItem[] | — | |
| max | number | — | Render at most this many avatars, then a "+N" chip. |
| overflowCount | number | — | Overrides the computed overflow count. |
| label | string | — | Accessible label for the whole stack, e.g. `'Team members'`. |
AvatarSurface
dahiliVaryant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| tone | soft | yellow | blue | green | pink | purple | red | soft |
CompactAvatarGroup
extends Omit< ComponentPropsWithoutRef<'div'>, 'children' >
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| items* | AvatarGroupItem[] | — | |
| size | sm | xs | 2xs | sm | 40px, 32px or 24px — the three sizes the design defines here. |
| appearance | stroke | default | default | |
| max | number | — | |
| label | string | — |
FlatAvatar
extends Omit< ComponentPropsWithoutRef<'svg'>, 'children' >
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| size | 3xl | 2xl | xl | lg | md | sm | xs | 2xs | 3xs | md | An Avatar size token or a pixel size. |
| background | number | 4 | Zero-based variant index of each Figma part. |
| face | number | 0 | |
| outfit | number | 0 | |
| hair | number | 0 | |
| eye | number | 0 | |
| cheek | number | null | 0 | Optional parts: omit (or `null`) to leave them off. |
| mouth | number | 0 | |
| glasses | number | null | — | |
| hat | number | null | — | |
| label | string | — | Accessible name. Without it the avatar is decorative. |