Pagination
Genel görünümimport { Pagination, PaginationAlign, PaginationEllipsis, PaginationLabels, PaginationSlot, PaginationType } from '@nili/ui';Bu, kütüphanenin kendi genel görünüm sayfası — canlı olarak render ediliyor. Üstten dili veya temayı değiştirin, o da değişir.
Temel
count sayfa sayısıdır; page birden başlar. defaultPage ile denetimsiz ya da page artı onPageChange ile denetimli.
import { Pagination } from "@nili/ui"
export function Example() {
const [page, setPage] = useState(3)
return (
<Pagination
count={16}
page={page}
onPageChange={setPage}
labels={{ root: "Pagination" }}
/>
)
}Türler
basic ayrı hücrelerdir; full-radius onları hap yapar; group onları tek bir bölümlü denetimde birleştirir.
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" />
</>
)
}Pencere
siblingCount, geçerli sayfanın iki yanında kaç sayfa duracağıdır; boundaryCount, her uçta kaçının sabit kalacağı. showEdges okların dışına ilk/son atlamalarını ekler.
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 />
</>
)
}Hizalama ve cihaz kipi
align satırı konumlandırır. Mobil cihaz kipi hücreleri bırakıp bir çift ok ve “16 sayfadan 3.” özetini koyar — on altı sayfalık bir iz telefona sığmaz.
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" />
</>
)
}Gelişmiş
advanced özeti izden önce, sayfa başına satır denetimini sonra ekler. Görünen her dize bir prop’tur — metnine sahip çıkan bir tasarım sistemi çeviri yığınını her tüketiciye dayatır.
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`,
}}
/>
)
}Devre dışı
Tüm denetimi soluklaştırır — örneğin yeniden yüklenen bir tablo.
import { Pagination } from "@nili/ui"
export function Example() {
return <Pagination count={16} defaultPage={3} disabled />
}Pagination
extends Omit< ComponentPropsWithoutRef<'nav'>, 'onChange' | 'children' >
Varyant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| align | start | center | end | between | center |
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| 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' >
Varyant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| fullRadius | boolean | false | Match the cells it sits among. Circles in Figma's Full Radius row. |
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| label | string | More pages | Accessible name; the glyph itself is hidden. |
PaginationGroup
dahiliPaginationItem
extends Omit< ComponentPropsWithoutRef<'button'>, 'children' >
Varyant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| 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. |
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| 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. |