Skip to content

Pagination

Controls for moving through a paged collection one page at a time, with automatic ellipses and configurable sibling/boundary counts.

  • stable
  • since v0.1.0
  • 2.4 kB
  • navigation
  • pagination
  • accessible

Renders inside a nav landmark with aria-label; current page button receives aria-current="page"; localisable labels via the labels prop.

Preview
Open
tsx

Use size="sm", "md" (default), or "lg" to match surrounding density.

Preview
Open
tsx

Set showFirstLast to render skip-to-first and skip-to-last buttons alongside Prev / Next.

Preview
Open
tsx

siblingCount (default 1) controls how many pages render either side of the current page; boundaryCount (default 1) controls how many pages stick to each end. Ellipses fill the gaps.

Preview
Open
tsx

Pass disabled to freeze the whole control (e.g. while loading the next page).

Preview
Open
tsx

Use the labels prop to translate or rewrite each button’s accessible name.

Preview
Open
tsx
PropTypeDefaultDescription
totalPages*
number
Total number of pages (1-indexed). Clamped to >= 1 internally.
currentPage*
number
Currently active page (1-indexed).
onPageChange*
(page: number) => void
Fired with the new page number when navigation occurs.
size
"sm"|"md"|"lg"
md
Visual size of the page buttons.
siblingCount
number
1
Number of siblings to display on either side of the current page before showing an ellipsis.
boundaryCount
number
1
Number of pages always rendered at the start and end of the range (before the ellipsis on either side).
showFirstLast
boolean
false
Render dedicated "first" / "last" jump buttons in the default layout.
disabled
boolean
false
Disable every control. Useful while a page transition is in flight.
labels
PaginationLabels
Localised labels for the navigation buttons.
children
ReactNode
Custom children compose their own layout (compound mode). Omit for the prop-driven default: Prev / page list / Next, optionally bracketed by First / Last.
aria-label
string
"Pagination"
Accessible label for the wrapping `<nav>` element.
  • The root renders a <nav> landmark; pass aria-label (default "Pagination") to name it.
  • Each page button receives a descriptive aria-label like "Go to page 4"; the current page is announced as "Page 4, current page".
  • The current button carries aria-current="page" so screen readers identify the active position.
  • Prev / Next / First / Last buttons become disabled (and unfocusable) at the edges of the range rather than disappearing.
  • Ellipsis placeholders are aria-hidden="true" so they don’t pollute announcements.
  • Sync currentPage to a ?page= URL search param so deep links survive refresh.
  • Lower siblingCount to 0 and raise boundaryCount to 2 for a compact “first … current … last” layout.
  • Pair with a Select for “items per page” controls in dense tables.
  • Customise labels.page to include the total count, e.g. (p) => `Go to page ${p} of 42`.