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