Loading component…
Loading component…
Pages of a long list
To reuse this local React demo, copy all files from the Code tab into the same folder, then import Pagination from ./pagination.
import { useState } from "react";
import { Pagination } from "@/components/ui/pagination";
export function RunsFooter({ total }: { total: number }) {
const [page, setPage] = useState(1);
const [pageSize, setPageSize] = useState(25);
return (
<Pagination
page={page}
onPageChange={setPage}
total={total}
pageSize={pageSize}
pageSizes={[25, 50, 100]}
onPageSizeChange={setPageSize}
/>
);
}| Name | Type | Default | Description |
|---|---|---|---|
| page | number | Required. The page shown, from 1 – kept between 1 and the last page | |
| onPageChange | (page: number) => void | Required. Called with the new page from the arrows, a number or a new size | |
| total | number | All rows. Shows the range ("1–25 of 1,284", "0 of 0" when empty) and works out the pages | |
| pageSize | number | 20 | Rows on a page |
| pageCount | number | The number of pages when you don't know the rows – the range becomes "Page 3 of 12" | |
| pageSizes | number[] | Shows Rows per page with these sizes (the current one is added when it's missing) | |
| onPageSizeChange | (pageSize: number) => void | A new size was picked. onPageChange follows with the page that holds the first row you saw | |
| siblings | number | 1 | Page numbers on each side of the current one; with the first, the last and two … that makes 2 × siblings + 5 slots |
| compact | boolean | false | Only the range and the arrows – no page numbers |
| disabled | boolean | false | While rows load: everything stays where it is, nothing can be pressed |
| aria-label | string | "Pagination" | Names the navigation landmark – say which list, when a page has two |
| ...nav props | ComponentProps<"nav"> | className, style, ref and the rest go to the <nav> |
Tabular numbers and a fixed count of slots, each as wide as the last page's number: the row keeps its width from page 1 to 10,000
When the row is too narrow for the numbers, only the range and the arrows stay; the range and the pager wrap onto two lines before that
Touch screens get 40px buttons and 15px text
Right to left: the arrows turn round
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"
@import "tailwindcss"; in your main CSS file.