Shadcn React Table

Search documentation

Search the docs

Pagination

The table pages its rows by default, ten to a page, with a page-size menu and first / previous / next / last buttons below the rows.

Page size and starting page

tsx
useDataTable({
  data,
  columns,
  getRowId: (row) => row.id,
  pageSizeOptions: [10, 25, 50],
  initialState: { pagination: { pageIndex: 0, pageSize: 25 } },
})

How the controls look

  • paginationDisplayMode: "default" — the row range ("1–10 of 48") with first / previous / next / last buttons.
  • paginationDisplayMode: "pages" — numbered page buttons.
  • paginationDisplayMode: "custom" — no built-in controls; render your own in renderBottomToolbarCustomActions, or place the exported DataTablePagination anywhere (see Composition).

positionPagination puts the controls at the "bottom" (default), "top", "both" or "none".

Numbered pagesNumbered page buttons above and below the table.
GitHub
Rows per page
ID
AvaThompsonOwnerEngineeringactive22$45,000Jan 2, 2023
0%
LiamNguyenAdminMarketinginactive25$47,137Jan 13, 2023
9%
NoahSilvaEditorDesignpending28$49,274Jan 24, 2023
18%
EmmaCarterViewerSalesactive31$51,411Feb 4, 2023
27%
OliviaRossiOwnerSupportinactive34$53,548Feb 15, 2023
36%
$10,578,180
Rows per page

Turning it off

enablePagination: false shows every row. Pair it with a bounded surface and virtualization for long lists, or with infinite scroll.

Server pagination

Set manualPagination: true, pass the total rowCount, and control state.pagination with onPaginationChange; the table renders the page you give it. See Server-side data.

Behavior worth knowing

  • Changing a filter or the search goes back to the first page.
  • When rows go away (a delete, a refetch) and the current page no longer exists, the table moves to the last page that does — except while isLoading, so a refetch doesn't jump pages.
  • The range text and page numbers follow the table's language (localization.language).

Relevant options

PropTypeDefaultDescription
enablePagination?booleantrueSplits rows into pages with pagination controls. Default `true`; turn it off for virtualization or infinite scroll.
pageSizeOptions?number[]DEFAULT_PAGE_SIZE_OPTIONSChoices in the rows-per-page select. Default `[5, 10, 25, 50, 100]`.
paginationDisplayMode?PaginationDisplayMode"default"Pagination control style: `"default"` (range label + first/prev/next/last buttons), `"pages"` (numbered page buttons), or `"custom"` (render your own via `renderBottomToolbarCustomActions`). Default "default".
positionPagination?"top" | "bottom" | "both" | "none""bottom"Where the pagination controls render. Default "bottom". "none" keeps pagination active but hides the controls.