KeyComponents
عرض شاملimport { ChartLegend, ChartLegendDot, ContentCard, ContentLabel, ControlLabel, HintText } from '@nili/ui';هذه صفحة العرض الشامل الخاصة بالمكتبة، معروضة حيّة. غيّر اللغة أو السمة من الأعلى وسَتتبعك.
التسمية
تسمية الحقل التي يستخدمها كل إدخال. والنجمة والتسمية الفرعية مخفيتان عن التقنيات المساعدة — فالإلزام تحمله خاصية required في الإدخال نفسه، وقارئ الشاشة الذي يسمع «رقم الهاتف نجمة اختياري» قيل له الشيء نفسه ثلاث مرات، مرتين منها متناقضتان.
import { Label, LinkButton } from "@nili/ui"
export function Example() {
return (
<>
<Label htmlFor="a">Email address</Label>
<Label htmlFor="b" required>Email address</Label>
<Label htmlFor="c" sublabel="(optional)">Email address</Label>
<Label htmlFor="d" information informationLabel="Why we ask">
Email address
</Label>
<Label htmlFor="e" hint={<LinkButton href="#" size="sm">Forgot?</LinkButton>}>
Password
</Label>
<Label htmlFor="f" disabled>Email address</Label>
</>
)
}نص التلميح
السطر تحت الحقل. يلوّنه status، ويضيف icon الرمز المناسب. وحالة error هي ما يرسمه Text Input حين تمرّر إليه error.
هذا نص تلميحي لمساعدة المستخدم.
أدخل عنوان بريد صالحًا من فضلك.
هذا الحقل غير متاح.
import { HintText } from "@nili/ui"
export function Example() {
return (
<>
<HintText icon>This is a hint text to help user.</HintText>
<HintText status="error" icon>Please enter a valid email.</HintText>
<HintText status="disabled">This field is unavailable.</HintText>
</>
)
}تسمية العنصر
صف التسمية الذي يبنيه Checkbox أو Radio أو Switch داخليًا — تسمية وتسمية فرعية وشارة ووصف وإجراء. وهو مُصدَّر لأن عنصرًا مخصّصًا ينبغي أن يبدو كالعناصر المدمجة.
import { ControlLabel, Badge, LinkButton } from "@nili/ui"
export function Example() {
return (
<ControlLabel
htmlFor="notify"
label="Email notifications"
sublabel="(recommended)"
badge={<Badge size="small" color="green" appearance="lighter">Free</Badge>}
description="We will only email you about things you asked for."
linkButton={<LinkButton href="#" size="sm">Manage</LinkButton>}
/>
)
}قوة كلمة المرور
أربعة مستويات. والمقياس وحده زخرفي — مرِّر label كي يُكتب الحكم لا أن يُترك للون.
import { PasswordStrength, TextInput } from "@nili/ui"
export function Example() {
return (
<>
<TextInput type="password" label="Password" />
<PasswordStrength strength="moderate" label="Could be stronger" />
</>
)
}الأيقونة المفتاحية
الأيقونة المؤطّرة التي تتصدّر نافذة أو حالة فارغة أو بطاقة محتوى. مظهران وعشرة ألوان وخمسة أحجام.
import { KeyIcon, Icon } from "@nili/ui"
import { RiSparkling2Line } from "@remixicon/react"
export function Example() {
return (
<>
<KeyIcon color="purple"><Icon icon={RiSparkling2Line} /></KeyIcon>
<KeyIcon color="purple" appearance="stroke"><Icon icon={RiSparkling2Line} /></KeyIcon>
<KeyIcon color="purple" size="2xl"><Icon icon={RiSparkling2Line} /></KeyIcon>
</>
)
}مفتاح الرسم البياني
مع onToggle يُرسم زرًّا بـaria-pressed، لأن تبديل سلسلة عنصر تحكّم. وبدونه نص عادي. وvalue منسّقة مسبقًا — فالأرقام قرار لغوي لا قرار المفتاح.
import { ChartLegend, ChartLegendDot } from "@nili/ui"
export function Example() {
const [hidden, setHidden] = useState<string[]>([])
return (
<>
{series.map((item) => (
<ChartLegend
key={item.key}
color={item.color}
value={item.value}
hidden={hidden.includes(item.key)}
onToggle={() => toggle(item.key)}
>
{item.label}
</ChartLegend>
))}
{/* just the dot */}
<ChartLegendDot color="blue" />
</>
)
}تسمية المحتوى وبطاقة المحتوى
عنوان مع فتحة متقدّمة وأخرى خلفية اختياريتين. ويرسم فيجما ستة أنواع — صورة رمزية وأيقونة وعلامة وشركة — وكلها startAdornment نفسها. وContent Card هي النسخة القابلة للاختيار.
import { ContentLabel, ContentCard, KeyIcon, Avatar, Icon, Badge } from "@nili/ui"
import { RiFolderLine } from "@remixicon/react"
export function Example() {
const [selected, setSelected] = useState("a")
return (
<>
<ContentLabel
startAdornment={<Avatar size="sm" name="Ada Lovelace" tone="blue" />}
title="Ada Lovelace"
description="Owner · ada@nili.design"
/>
<ContentCard
selected={selected === "a"}
onSelect={() => setSelected("a")}
startAdornment={
<KeyIcon size="md" color="blue"><Icon icon={RiFolderLine} /></KeyIcon>
}
title="Design system"
description="24 components · updated 2 days ago"
badge={<Badge size="small" color="green" appearance="lighter">v0.2</Badge>}
/>
</>
)
}ChartLegend
extends Omit< ComponentPropsWithoutRef<'button'>, 'color' | 'disabled' | 'value' >
باقي الخصائص
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| children | ReactNode | — | |
| disabled | boolean | — | |
| required | boolean | — | |
| readOnly | boolean | — | |
| value | ReactNode | — | Trailing figure — pre-formatted, since numerals are a locale decision. |
| defaultValue | string | — | |
| name | string | — | |
| aria-label | string | — | |
| color | yellow | blue | green | pink | purple | red | gray | orange | sky | teal | disabled | light-gray | blue | |
| size | md | sm | md | |
| hidden | boolean | false | Series is hidden. Renders `aria-pressed` so the state is announced. |
| onToggle | () => void | — | Clicking toggles the series. Without it, renders as plain text. |
ChartLegendDot
extends Omit< ComponentPropsWithoutRef<'span'>, 'color' >
باقي الخصائص
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| color | yellow | blue | green | pink | purple | red | gray | orange | sky | teal | disabled | light-gray | blue | |
| size | md | sm | md |
ContentCard
extends ContentLabelProps
باقي الخصائص
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| onSelect | () => void | — | Renders a `<button>` so the whole card is keyboard reachable. |
| selected | boolean | false | |
| startAdornment | ReactNode | — | Flag, icon, avatar, brand mark — all five Figma Types land here. |
| endAdornment | ReactNode | — | |
| title* | ReactNode | — | |
| sublabel | ReactNode | — | Figma `💬 Sublabel` — the muted run *beside* the title, on the same line. |
| description | ReactNode | — | |
| badge | ReactNode | — | Figma `🎖️ Badge` — sits after the title, before any sublabel. |
| required | boolean | — | Figma `🚨 Required` — the asterisk after the title. Decorative. |
| toggle | ReactNode | — | Figma `🔀 Toggle` — trailing control. Rendered after `endAdornment`. |
| size | lg | md | — |
ContentLabel
extends Omit< ComponentPropsWithoutRef<'div'>, 'title' >
باقي الخصائص
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| startAdornment | ReactNode | — | Flag, icon, avatar, brand mark — all five Figma Types land here. |
| endAdornment | ReactNode | — | |
| title* | ReactNode | — | |
| sublabel | ReactNode | — | Figma `💬 Sublabel` — the muted run *beside* the title, on the same line. |
| description | ReactNode | — | |
| badge | ReactNode | — | Figma `🎖️ Badge` — sits after the title, before any sublabel. |
| required | boolean | false | Figma `🚨 Required` — the asterisk after the title. Decorative. |
| toggle | ReactNode | — | Figma `🔀 Toggle` — trailing control. Rendered after `endAdornment`. |
| size | lg | md | md |
ControlLabel
extends Omit< ComponentPropsWithoutRef<'span'>, 'children' >
باقي الخصائص
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| htmlFor | string | — | Ties the label to its control. Omit when the label is not a `<label>`. |
| label | ReactNode | — | |
| sublabel | ReactNode | — | Muted text sitting inline *after* the label — "(optional)", a unit, a count. Figma's `Sublabel`. Distinct from `description`, which is a second line rather than a continuation of the first. |
| description | ReactNode | — | Second line under the label. Figma's `Description`. |
| badge | ReactNode | — | Trailing slot on the label row — a `<Badge>`. |
| linkButton | ReactNode | — | Action under the description — a `<LinkButton>`. |
| disabled | boolean | false | |
| descriptionId | string | — | Wired to the control's `aria-describedby`. |
HintText
extends ComponentPropsWithoutRef<'p'>, VariantProps<typeof hintTextVariants>
باقي الخصائص
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| icon | boolean | ReactNode | false | `true` shows the default glyph for the status; a node overrides it. |
KeyIcon
extends Omit< ComponentPropsWithoutRef<'span'>, 'color' >
باقي الخصائص
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| children* | ReactNode | — | |
| aria-label | string | — | |
| appearance | lighter | stroke | lighter | |
| color | yellow | blue | green | pink | purple | red | gray | orange | sky | primary | primary | |
| size | 2xl | xl | lg | md | sm | lg | |
| label | string | — | Provide only when the icon carries meaning alone. Usually it does not. |
Label
extends ComponentPropsWithoutRef<'label'>, VariantProps<typeof labelVariants>
باقي الخصائص
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| required | boolean | false | Adds an asterisk and, crucially, keeps it out of the accessible name. |
| sublabel | ReactNode | — | Figma `💬 Sublabel` — the muted "(Optional)" after the asterisk. |
| information | boolean | ReactNode | false | Figma `ℹ️ Information` — the glyph that explains the field. |
| informationLabel | string | — | Accessible name for the information glyph. |
| hint | ReactNode | — | Figma `🌟 Button` — trailing slot, usually a LinkButton. |
| rowClassName | string | — | Applied to the row rather than to the `<label>` element. |
PasswordStrength
extends Omit< ComponentPropsWithoutRef<'div'>, 'children' >
باقي الخصائص
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| strength | strong | empty | weak | moderate | empty | |
| label | string | — | Visible text beside the meter, e.g. "Strong password". |