Components
Pagination
Numbered pages with ellipses for long ranges.
<Pagination page={page} onChange={setPage} total={20} />Installation
npx shadcn@latest add https://ui.zjkm.tech/r/pagination.jsonimport { Pagination } from "@/components/pagination"Using JavaScript? Set tsx: false in components.json and the CLI converts it.
New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.
Usage
Numbered pages with Previous and Next. Long ranges collapse into ellipses, keeping the first and last pages and the ones around the current page. pageList is exported if you want the same numbers elsewhere.
import { Pagination } from "@/components/pagination";
export function Results({ total }: { total: number }) {
const [page, setPage] = useState(1);
return <Pagination page={page} total={total} onChange={setPage} />;
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
page | number | The current page, from 1. | |
total | number | Number of pages. | |
onChange | (page: number) => void | Called with the chosen page. | |
siblings | number | 1 | Pages shown either side of the current one. |
label | string | "Pagination" | Accessible name. |
className | string | Classes for the nav. |
It has no animation, so reduced motion changes nothing.