Avatar
نمای کلیimport { Avatar, AvatarGroup, CompactAvatarGroup, FlatAvatar } from '@nili/ui';این همان صفحهی نمای کلیِ خود کتابخانه است که زنده رندر میشود. زبان یا تم را از هدر عوض کنید، همراهش میآید.
اندازهها
نُه اندازه، از ۸۰ تا ۱۶ پیکسل. name الزامی است: آواتار بینام یا تصویری بیبرچسب است یا یک لکهٔ تزئینی، و فقط محل استفاده میداند کدام. برای تزئینیکردنش رشتهٔ خالی بدهید.
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" />
</>
)
}جایگزینها
بدون تصویر، حروف اول از name درمیآید. با initials بازنویسیشان کنید، با fallback کاملاً جایگزینشان کنید، یا برای شبح از placeholder استفاده کنید — حسابی که نه عکس دارد و نه نامی که ارزش مخففشدن داشته باشد.
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 />
</>
)
}تنها
فیگما روی Avatar محور رنگ ندارد — تنها یک افزودهاند و برای گروهها وجود دارند: پشتهٔ شش دایرهٔ خاکستریِ یکسان خوانا نیست، و رنگزدنشان ارزانترین راه تشخیصشان پیش از بارگذاری تصویرهاست.
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" />
</>
)
}وضعیتها
یک نشانگر بالا و یکی پایین. به آن statusLabel بدهید — یک نقطهٔ رنگی نام دسترسپذیری ندارد. همهٔ اندازهها نمیتوانند نشانگر بگیرند؛ سر کوچک طیف بهجای کشیدن یک لکهٔ ناخوانا، نشانگر را حذف میکند.
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"
/>
</>
)
}گروه آواتار
یک پشته با چیپ «+N». max سقف تعداد رسمشده را میگذارد؛ overflowCount باقیماندهٔ محاسبهشده را بازنویسی میکند وقتی فهرستی که در دست دارید فقط یک صفحه از مجموعهای بزرگتر است.
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" />
</>
)
}گروه آواتار فشرده
پشتهای فشردهتر داخل یک قرص — برای ردیفهای جدول و آیتمهای فهرست، جایی که فاصلهگذاری Avatar Group زیادی سخاوتمند است. سه اندازه، دو پرداخت.
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" />
</>
)
}آواتار تخت
آواتار تصویرسازیشده، ساختهشده از قطعات جایگزینپذیر فیگما. اندیسها دور میزنند، پس هر عددی انتخابی معتبر و قطعی است — برای ساختن آواتاری پایدار از شناسهٔ کاربر به کار میآید.
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' >
محورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| size | 3xl | 2xl | xl | lg | md | sm | xs | 2xs | 3xs | md |
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| 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' >
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| 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
داخلیمحورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| tone | soft | yellow | blue | green | pink | purple | red | soft |
CompactAvatarGroup
extends Omit< ComponentPropsWithoutRef<'div'>, 'children' >
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| 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' >
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| 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. |