StepIndicator
نمای کلیimport { Step, StepIndicator, StepIndicatorLabels, StepperDot } from '@nili/ui';این همان صفحهی نمای کلیِ خود کتابخانه است که زنده رندر میشود. زبان یا تم را از هدر عوض کنید، همراهش میآید.
افقی
value اندیس گام فعلی است و از صفر شروع میشود. هرچه پیش از آن است کاملشده خوانده میشود و هرچه پس از آن، پیشفرض — هر سه حالت مجانی از روی موقعیت درمیآیند.
import { StepIndicator, Step } from "@nili/ui"
export function Example() {
return (
<StepIndicator value={1} labels={{ root: "Checkout" }}>
<Step label="Account" />
<Step label="Profile" />
<Step label="Billing" />
<Step label={t('step.done')} />
</StepIndicator>
)
}همراه با توضیح
یک خط دوم زیر برچسب. کوتاه نگهش دارید — نشانگر نقشهٔ مسیر است، نه خود مسیر.
import { StepIndicator, Step } from "@nili/ui"
export function Example() {
return (
<StepIndicator value={2} labels={{ root: "Checkout" }}>
<Step label="Account" description="Email and password" />
<Step label="Profile" description="Name and photo" />
<Step label="Billing" description="Card details" />
</StepIndicator>
)
}عمودی
همان کامپوننت، رویهمچیده. برای سایدبار مناسب است، یا برای مسیری با برچسبهای بلند که هرگز در یک ردیف جا نمیشوند.
import { StepIndicator, Step } from "@nili/ui"
export function Example() {
return (
<StepIndicator orientation="vertical" value={1} labels={{ root: "Setup" }}>
<Step label="Account" description="Email and password" />
<Step label="Profile" description="Name and photo" />
<Step label="Billing" description="Card details" />
</StepIndicator>
)
}گامهای قابلبازگشت
onSelect یک گام را به دکمهٔ واقعی تبدیل میکند — برای ویزاردی که میشود به گامهای قبلش برگشت. بدون آن گام فقط متنی بیجان است، و وقتی مسیر اکیداً رو به جلوست همین درست است.
import { StepIndicator, Step } from "@nili/ui"
export function Example() {
const [current, setCurrent] = useState(1)
return (
<StepIndicator value={current} labels={{ root: "Checkout" }}>
{steps.map((step, index) => (
<Step
key={step.label}
label={step.label}
onSelect={index <= current ? () => setCurrent(index) : undefined}
/>
))}
</StepIndicator>
)
}نشانگرهای سفارشی و وضعیت تحمیلی
icon جای عدد یا تیک را میگیرد. status وضعیتی را که از value نشانگر درآمده بازنویسی میکند — بهندرت لازم میشود، ولی برای گامی هست که اعتبارسنجیاش شکست خورده و باید علامتخورده بماند.
import { StepIndicator, Step, Icon } from "@nili/ui"
import { RiUser3Line, RiCheckLine } from "@remixicon/react"
export function Example() {
return (
<StepIndicator value={1} labels={{ root: "Setup" }}>
<Step label={t('step.account')} icon={<Icon icon={RiCheckLine} />} />
<Step label={t('step.profile')} icon={<Icon icon={RiUser3Line} />} />
<Step label={t('step.billing')} status="completed" />
</StepIndicator>
)
}نقطهٔ گامشمار
شکل فشرده: بدون برچسب، فقط موقعیت. برای کاروسلهای آشناسازی و شیتهای موبایل، جایی که نشانگر برچسبدار تمام صفحه را میگیرد.
import { StepperDot } from "@nili/ui"
export function Example() {
return (
<>
<StepperDot count={4} value={1} label="Onboarding" />
<StepperDot count={4} value={1} size="xs" label="Onboarding" />
</>
)
}Step
extends Omit< ComponentPropsWithoutRef<'button'>, 'value' >
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| children | ReactNode | — | |
| disabled | boolean | — | |
| required | boolean | — | |
| readOnly | boolean | — | |
| value | string | — | |
| defaultValue | string | — | |
| name | string | — | |
| aria-label | string | — | |
| label | ReactNode | — | |
| description | ReactNode | — | |
| status | default | completed | active | — | Overrides the state derived from the indicator's `value`. Rarely needed — all three states follow from the position for free. |
| icon | ReactNode | — | Replaces the number or the tick. |
| onSelect | () => void | — | Makes the step a real button — for a wizard whose earlier steps can be revisited. Without it the step is inert text, which is right when the flow is strictly forward. |
StepConnector
داخلیمحورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| orientation | horizontal | vertical | horizontal | |
| complete | 'true' | 'false' | false |
StepDescription
داخلیStepIndicator
extends Omit< ComponentPropsWithoutRef<'nav'>, 'children' >
محورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| orientation | horizontal | vertical | horizontal |
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| children* | ReactNode | — | |
| aria-label | string | — | |
| value | number | 0 | Index of the current step, 0-based. |
| locale | string | — | BCP-47 tag for the step numbers (`'fa'` → Persian). Defaults to the ambient locale from `NiliProvider`. |
| labels | StepIndicatorLabels | — |
StepItem
داخلیمحورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| orientation | horizontal | vertical | horizontal | |
| interactive | 'true' | 'false' | false |
StepLabel
داخلیمحورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| status | completed | active | default | default |
StepMarker
داخلیمحورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| status | completed | active | default | default |
StepperDot
extends Omit< ComponentPropsWithoutRef<'div'>, 'children' >
محورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| size | sm | xs | sm | |
| active | 'true' | 'false' | false |
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| count | number | 3 | Number of dots. |
| value | number | 0 | Index of the active dot, 0-based. Figma's "1st / 2nd / 3rd Active". |
| label | string | — | Accessible name, e.g. `'Form steps'`. |
| formatProgress | (index: string, total: string) => string | — | How the position is announced. |
| locale | string | — |