Pagination
عرض شاملimport { Pagination, PaginationAlign, PaginationEllipsis, PaginationLabels, PaginationSlot, PaginationType } from '@nili/ui';هذه صفحة العرض الشامل الخاصة بالمكتبة، معروضة حيّة. غيّر اللغة أو السمة من الأعلى وسَتتبعك.
أساسي
count هو عدد الصفحات، وpage يبدأ من واحد. غير متحكَّم به عبر defaultPage، أو متحكَّم به عبر page مع onPageChange.
import { Pagination } from "@nili/ui"
export function Example() {
const [page, setPage] = useState(3)
return (
<Pagination
count={16}
page={page}
onPageChange={setPage}
labels={{ root: "Pagination" }}
/>
)
}الأنواع
النوع basic خلايا منفصلة، وfull-radius يجعلها أقراصًا، وgroup يضمّها في عنصر مجزّأ واحد.
import { Pagination } from "@nili/ui"
export function Example() {
return (
<>
<Pagination count={16} defaultPage={3} type="basic" />
<Pagination count={16} defaultPage={3} type="full-radius" />
<Pagination count={16} defaultPage={3} type="group" />
</>
)
}النافذة
siblingCount هو عدد الصفحات على جانبي الصفحة الحالية، وboundaryCount هو عدد ما يبقى مثبّتًا في كل طرف. ويضيف showEdges قفزات البداية والنهاية خارج الأسهم.
import { Pagination } from "@nili/ui"
export function Example() {
return (
<>
<Pagination count={40} defaultPage={20} siblingCount={1} />
<Pagination count={40} defaultPage={20} siblingCount={2} boundaryCount={2} />
<Pagination count={40} defaultPage={20} showEdges />
</>
)
}المحاذاة ووضع الجهاز
يحدّد align موضع الصف. ويُسقط وضع الهاتف الخلايا لصالح سهمين وملخّص «الصفحة ٣ من ١٦» — فمسار من ست عشرة صفحة لا يتّسع على الهاتف.
import { Pagination } from "@nili/ui"
export function Example() {
return (
<>
<Pagination count={16} defaultPage={3} align="start" />
<Pagination count={16} defaultPage={3} align="between" />
<Pagination count={16} defaultPage={3} deviceMode="mobile" />
</>
)
}متقدّم
يضيف advanced الملخّص قبل المسار وعنصر عدد الصفوف بعده. وكل نص ظاهر هو خاصية — فنظام تصميم يملك نصوصه يفرض طبقة ترجمته على كل مستهلك.
import { Pagination } from "@nili/ui"
export function Example() {
const [page, setPage] = useState(1)
const [pageSize, setPageSize] = useState(10)
return (
<Pagination
advanced
count={16}
page={page}
onPageChange={setPage}
pageSize={pageSize}
pageSizeOptions={[10, 20, 50]}
onPageSizeChange={setPageSize}
labels={{
root: "Pagination",
summary: (page, count) => `Page ${page} of ${count}`,
perPage: (size) => `${size} / page`,
}}
/>
)
}معطّل
يجعل العنصر كله رماديًا — كجدول يعيد التحميل مثلًا.
import { Pagination } from "@nili/ui"
export function Example() {
return <Pagination count={16} defaultPage={3} disabled />
}Pagination
extends Omit< ComponentPropsWithoutRef<'nav'>, 'onChange' | 'children' >
محاور التنويع — من تعريف cva للمكوّن
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| align | start | center | end | between | center |
باقي الخصائص
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| count* | number | — | Total number of pages. Anything below 1 renders nothing. |
| page | number | — | Current page, 1-based. Controlled. |
| defaultPage | number | 1 | Starting page while uncontrolled. |
| onPageChange | (page: number) => void | — | |
| siblingCount | number | 1 | Pages either side of the current one. |
| boundaryCount | number | 1 | Pages pinned at each end of the trail. |
| type | basic | full-radius | group | basic | |
| deviceMode | desktop | mobile | desktop | Figma's `Device Mode`. `mobile` shows arrows plus a summary, not cells. |
| showEdges | boolean | false | Adds first/last jumps outside the arrows. |
| disabled | boolean | false | Greys out the whole control — a table reloading, for instance. |
| advanced | boolean | false | Figma's `🧪 Advanced`. Adds the "Page 2 of 16" summary before the trail and the rows-per-page control after it. |
| pageSize | number | — | Rows per page. Only rendered when `advanced`. |
| pageSizeOptions | number[] | — | Choices offered by the per-page control. |
| onPageSizeChange | (pageSize: number) => void | — | |
| locale | string | — | BCP-47 tag driving the digits (`'fa'` → Persian). Defaults to the ambient locale from `NiliProvider`. |
| labels | PaginationLabels | — |
PaginationEllipsis
extends Omit< ComponentPropsWithoutRef<'span'>, 'children' >
محاور التنويع — من تعريف cva للمكوّن
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| fullRadius | boolean | false | Match the cells it sits among. Circles in Figma's Full Radius row. |
باقي الخصائص
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| label | string | More pages | Accessible name; the glyph itself is hidden. |
PaginationGroup
داخليPaginationItem
extends Omit< ComponentPropsWithoutRef<'button'>, 'children' >
محاور التنويع — من تعريف cva للمكوّن
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| active | boolean | false | The page you are on: adds `aria-current="page"`. |
| fullRadius | boolean | false | Figma's `Full Radius`: a pill cell instead of a rounded rectangle. |
باقي الخصائص
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| children | ReactNode | — | |
| disabled | boolean | — | |
| required | boolean | — | |
| readOnly | boolean | — | |
| value | string | — | |
| defaultValue | string | — | |
| name | string | — | |
| aria-label | string | — | |
| asChild | boolean | false | Render the child element instead of a `<button>` — for router links. |