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" />
</>
)
}برچسب محتوا و کارت محتوا
یک عنوان با اسلات پیشرو و انتهایی اختیاری. فیگما شش Type میکشد — آواتار، آیکون، برند، شرکت — و همه همان 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". |