ProgressBar
نمای کلیimport { ProgressBar, ProgressCircle } from '@nili/ui';این همان صفحهی نمای کلیِ خود کتابخانه است که زنده رندر میشود. زبان یا تم را از هدر عوض کنید، همراهش میآید.
پایه
value بین ۰ تا max محدود میشود. نواری که برچسب دیدهشدنی ندارد به aria-label نیاز دارد — در یک سلول جدول چیز دیگری برای نامدادن به آن نیست.
import { ProgressBar } from "@nili/ui"
export function Example() {
return (
<>
<ProgressBar value={35} aria-label={t('upload')} />
<ProgressBar value={70} label={t('storage')} showValue />
<ProgressBar value={7} max={10} label="Files" valueLabel="7 of 10 files" />
</>
)
}رنگها
چهار رنگ. رنگ یک سیگنال است نه تزئین — warning و error باید یعنی عدد بد است، نه صرفاً بزرگ.
import { ProgressBar } from "@nili/ui"
export function Example() {
return (
<>
<ProgressBar value={40} color="primary" label="Primary" />
<ProgressBar value={100} color="success" label="Success" />
<ProgressBar value={85} color="warning" label="Warning" />
<ProgressBar value={95} color="error" label="Error" />
</>
)
}جای برچسب و کنشها
labelPosition همان On Top / On Right فیگماست و منطقی است — end از جهت خواندن پیروی میکند. linkButton کنشی است که زیر نوار مینشیند.
import { ProgressBar, LinkButton } from "@nili/ui"
export function Example() {
return (
<>
<ProgressBar value={60} label="Storage" labelPosition="top" showValue />
<ProgressBar value={60} label="Storage" labelPosition="end" showValue />
<ProgressBar
value={92}
color="warning"
label="Storage"
showValue
linkButton={<LinkButton href="#" size="sm">Upgrade plan</LinkButton>}
/>
</>
)
}نامعیّن
برای کاری که مدتش معلوم نیست. aria-valuenow را حذف میکند، پس فناوری کمکی «مشغول» را اعلام میکند بهجای اینکه درصدی از خودش بسازد.
import { ProgressBar, ProgressCircle } from "@nili/ui"
export function Example() {
return (
<>
<ProgressBar indeterminate label={t('indet.syncing')} />
<ProgressCircle indeterminate aria-label={t('indet.loading')} />
</>
)
}دایرهٔ پیشرفت
همان API در قالب یک حلقه. شش اندازه، و thickness برحسب پیکسل وقتی ضخامت پیشفرض به کار نمیآید.
import { ProgressCircle } from "@nili/ui"
export function Example() {
return (
<>
<ProgressCircle value={65} showValue aria-label="Complete" />
<ProgressCircle value={65} size={80} showValue aria-label="Complete" />
<ProgressCircle value={65} thickness={2} showValue aria-label="Complete" />
{/* anything in the middle */}
<ProgressCircle value={65} aria-label="Complete">
<span className="text-[12px]">65/100</span>
</ProgressCircle>
</>
)
}ProgressBar
extends ProgressCommonProps, Omit<ComponentPropsWithoutRef<'div'>, 'color' | 'children'>
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | Accessible name when there is no visible `label` — a bare bar in a table cell has nothing to be named by otherwise. |
| value | number | 0 | Current value, clamped to `0…max`. Ignored while `indeterminate`. |
| max | number | 100 | |
| color | error | warning | success | primary | primary | |
| indeterminate | boolean | false | Unknown duration: drops `aria-valuenow` so assistive tech announces "busy" rather than inventing a percentage. |
| label | ReactNode | — | Visible label. Also becomes the accessible name. |
| labelPosition | end | top | top | Figma's label `Type`. |
| linkButton | ReactNode | — | Action under the bar. Figma's "Link Button". |
| showValue | boolean | false | Shows the percentage. |
| valueLabel | ReactNode | — | Overrides the rendered readout — `'3 of 10 files'`, a size, an ETA. |
| locale | string | — | BCP-47 tag driving the digits (`'fa'` → Persian). Defaults to the ambient locale from `NiliProvider`. |
ProgressCircle
extends ProgressCommonProps, Omit<ComponentPropsWithoutRef<'div'>, 'color' | 'children'>
محورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| size | 80 | 72 | 64 | 56 | 48 | 40 | 64 |
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| children | ReactNode | — | Content in the middle. Defaults to the percentage when `showValue`. |
| aria-label | string | — | Accessible name when there is no visible `label` — a bare bar in a table cell has nothing to be named by otherwise. |
| thickness | number | — | Stroke width in px. |
| value | number | 0 | Current value, clamped to `0…max`. Ignored while `indeterminate`. |
| max | number | 100 | |
| color | error | warning | success | primary | primary | |
| indeterminate | boolean | false | Unknown duration: drops `aria-valuenow` so assistive tech announces "busy" rather than inventing a percentage. |
| label | ReactNode | — | Visible label. Also becomes the accessible name. |
| labelPosition | end | top | — | Figma's label `Type`. |
| linkButton | ReactNode | — | Action under the bar. Figma's "Link Button". |
| showValue | boolean | true | Shows the percentage. |
| valueLabel | ReactNode | — | Overrides the rendered readout — `'3 of 10 files'`, a size, an ETA. |
| locale | string | — | BCP-47 tag driving the digits (`'fa'` → Persian). Defaults to the ambient locale from `NiliProvider`. |
ProgressCircleStroke
داخلیمحورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| color | primary | success | warning | error | primary |
ProgressCommon
داخلیبقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| value | number | — | Current value, clamped to `0…max`. Ignored while `indeterminate`. |
| max | number | — | |
| color | error | warning | success | primary | — | |
| indeterminate | boolean | — | Unknown duration: drops `aria-valuenow` so assistive tech announces "busy" rather than inventing a percentage. |
| label | ReactNode | — | Visible label. Also becomes the accessible name. |
| labelPosition | end | top | — | Figma's label `Type`. |
| linkButton | ReactNode | — | Action under the bar. Figma's "Link Button". |
| showValue | boolean | — | Shows the percentage. |
| valueLabel | ReactNode | — | Overrides the rendered readout — `'3 of 10 files'`, a size, an ETA. |
| locale | string | — | BCP-47 tag driving the digits (`'fa'` → Persian). Defaults to the ambient locale from `NiliProvider`. |
| aria-label | string | — | Accessible name when there is no visible `label` — a bare bar in a table cell has nothing to be named by otherwise. |
ProgressFill
داخلیمحورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| color | primary | success | warning | error | primary | |
| indeterminate | 'true' | 'false' | false |
ProgressLabel
داخلیمحورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| position | top | end | top |