Page navigation made of real links. The current page gets aria-current="page", long ranges collapse into an ellipsis, Previous and Next are disabled at the ends. Server component, no JavaScript: it works without hydration and every page opens in a new tab.
Preview
Installation
Usage
import { Pagination } from "@/components/ui/pagination"
export default function Example() {
return <Pagination page={5} pageCount={20} href="/blog?page={page}" />
}Examples
URL template
href accepts a string with {page} or a function (page) => string. In this demo the links only change the hash.
<Pagination
page={1}
pageCount={12}
siblings={2}
href={(p) => `/items/${p}`}
/>Icon only and few pages
iconOnly keeps the chevrons; with a small pageCount there is no ellipsis.
<Pagination page={3} pageCount={5} iconOnly href="?page={page}" />Custom texts
Texts are English by default; pass your own for any language.
<Pagination
page={20}
pageCount={20}
href="?page={page}"
previousLabel="Back"
nextLabel="Forward"
label="Navigation"
pageLabel={(n) => `Page ${n}`}
/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| page | number | - | Current page, 1-based |
| pageCount | number | - | Total number of pages |
| href | string | ((page: number) => string) | - | URL template with {page}, or a function that returns the URL of a page |
| siblings | number | 1 | Pages shown on each side of the current one |
| boundary | number | 1 | Pages always shown at both ends |
| previousLabel | string | "Previous" | Text of the previous link |
| nextLabel | string | "Next" | Text of the next link |
| label | string | "Pagination" | Accessible name of the nav landmark |
| pageLabel | (page: number) => string | (n) => `Page ${n}` | Builds the accessible name of a page link |
| iconOnly | boolean | false | Hide the Previous/Next text and keep only the chevrons |