Talisman LogoTalisman Logo Design System
Browse documentation
Components

Pagination controls

The pagination bar for tables and lists, with page size, page indicator and navigation, that keeps the page and size in the URL.

Stableimport { Pagination } from "@repo/ui/pagination-controls";Source

Use the buttons to change page and the selector to change the page size. The page and size live in the URL (page_number and page_size), so the preview provides a URL of its own.

When to use

  • Under a table or list that the backend returns in pages.
  • When the page and page size must survive a reload and be shareable in a link.
  • When the user needs to pick how many rows they see (25, 50 or 100 by default).

When not to use

  • Numbered links that go to separate pages. Compose the parts of Pagination.
  • A short list that fits on the page. Show it all.
  • Switching between views. Use Tabs.
  • Lists that load more as the user scrolls. Use a “Carregar mais” button.

Examples

Default

Shows page size, a “Página 3 de 12” indicator, and first, previous, next and last buttons. First and previous are disabled on page 1.

First page

With the total of records

Set showTotalRecords to say how many records exist next to the page size.

Page numbers

pageNumberLayout="leadingOne" adds a strip of page numbers that always starts at 1: 1 … 5 6 7 … 50. It replaces the first-page button.

Unknown total

When the backend does not return the total, set hideLastPage. The last-page button and the indicator disappear and next stays on while has_next_page is true.

The page-number strip

The strip is built by getFixedPageNumberStrip(currentPage, { totalPages, windowSize }) in @repo/ui/pagination-page-numbers. It has a fixed number of slots (5 by default, minimum 3), so the bar does not change width while the user pages. The first page is always shown, and the last page too when the total is known.

Current page Total Strip (5 slots)
1 50 1 2 3 … 50
6 50 1 … 5 6 7 … 50
49 50 1 … 47 48 49 50
4 3 1 2 3 (page clamped)

PaginationLeadingOnePages renders the strip as buttons from @repo/ui/pagination-leading-one-pages. Use it on its own when you manage the page yourself.

Página atual: 6

Content

  • Pass every string through labels. The package has no translations: the app passes them, as apps/app does in usePaginationLabels.
  • perPage follows the selector: “por página”. With showTotalRecords, perPageWithTotal(total) replaces it: “por página, de 287”.
  • pageIndicator(current, total) returns the whole sentence: “Página 3 de 12”. Use next-intl plural rules in the app when the copy needs them.
  • Tooltips are short and name the action: “Próxima página”, “Última página”.

Accessibility

  • The buttons are Button elements inside a nav named by labels.navAriaLabel. Tab moves between them, Enter or Space activates them, and disabled buttons leave the tab order.
  • Tooltips come from Radix Tooltip: they show on hover and keyboard focus, and Escape hides them. The buttons keep their own aria-label, so tooltips are not the only name.
  • The page-size selector is a Base UI Select. The arrow keys, Home, End and typing move through options, Enter picks and Escape closes. It is named by labels.perPage and connected to its visible label.
  • While isPlaceholderData is true, the navigation buttons are disabled so the user cannot queue page changes.
  • The current page in the strip has aria-current="page". Page-number buttons are not named: their text is only the number (see Known issues).
  • Below the md breakpoint (768px) the page-size selector and the indicator are hidden; only the navigation stays.

Code

import { Pagination } from "@repo/ui/pagination-controls";
import type { PaginationLabels } from "@repo/ui/pagination-controls";

const labels: PaginationLabels = {
  firstPage: "Primeira página",
  lastPage: "Última página",
  navAriaLabel: "Paginação dos processos",
  next: "Próxima página",
  pageIndicator: (current, total) => `Página ${current} de ${total}`,
  perPage: "por página",
  perPageWithTotal: (total) => `por página, de ${total}`,
  previous: "Página anterior",
};

<Pagination
  dataPagination={data?.pagination}
  isPlaceholderData={isPlaceholderData}
  labels={labels}
  pageNumberLayout="leadingOne"
/>;

The component reads and writes page_number, page_size and q through nuqs. The app must be wrapped in a nuqs adapter.

Props

Pagination
PropTypeDefaultDescription
clearSelection() => void—Called when the page size shrinks, so the list can clear selected rows that left the page
dataPaginationPaginationType | undefined—Pagination block returned by the backend. Not read while it is `undefined`
defaultPageSizenumber25Page size used when the URL has none
hideLastPagebooleanfalseHides the last-page jump and the page indicator. Use when the total is unknown
isPlaceholderDataboolean—True while the next page loads. Disables the navigation controls
labelsPaginationLabels—Every visible and accessible string, translated by the app
pageNumberLayout"default" | "leadingOne"default`leadingOne` adds a strip of page numbers (`1 … 9 10 11 … 50`) and drops the first-page button
pageNumberWindowSizenumber5Slots in the page-number strip for `leadingOne`
pageSizeOptionsnumber[][25, 50, 100]Page sizes offered in the selector
showTotalRecordsbooleanfalseShows the total of records next to the page size
PaginationType
PropTypeDefaultDescription
current_pagenumber—Current page, starting at 1.
total_pagesnumber | null—Total of pages. `null` when unknown.
total_recordsnumber | null—Total of records. `null` when unknown.
has_next_pageboolean—Enables next and last.
next_page, prev_pagenumber | null—Neighbour pages. Part of the type; the component navigates by URL.
page_size, search_stringnumber, string—Echo of the request. Part of the type.
PaginationLabels
PropTypeDefaultDescription
perPagestring—Label after the page-size selector.
perPageWithTotal(total: number) => string—Label with the total, used with `showTotalRecords`.
navAriaLabelstring—Accessible name of the navigation landmark.
firstPage, previous, next, lastPagestring—Tooltip of each navigation button.
pageIndicator(current: number, total: number) => string—The sentence for the current page, such as "Página 3 de 12".

Known issues

Issue Effect
The page state comes from nuqs (page_number, page_size, q) with no fallback. Without a nuqs adapter above it the control does not work. It cannot be used with state outside the URL.
After a page change the hook scrolls the element with id table-container. The table must use that exact id to scroll back to the top. The coupling is hidden from the props.
The page-size selector and the page indicator have hidden ... md:flex. On small viewports users cannot change the page size or see the total of pages.
PaginationPageButton shows only the number and has no aria-label or labels prop. Screen readers announce “6, button” with no mention of a page, and the name cannot be translated.
Edit this page on GitHub