Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Data Table examples · Standard

Paginated Data Table for React

A table of transactions, five per page, with Previous and Next buttons and the current page number.

Framework
UI library

Eight transactions split into pages of five, with Page 1 of 2 on one side and Previous and Next on the other. TanStack Table's pagination keeps the page; the buttons step through it and turn off at either end. Use it for histories, logs and any list longer than a screen.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

How many rows are on a page?

Five: initialState.pagination sets pageSize to 5, and getRowModel() returns that page through rowPaginationFeature and createPaginatedRowModel(). Call table.setPageSize to change it.

How do Previous and Next work?

They call table.previousPage() and table.nextPage(), and each is disabled when getCanPreviousPage() or getCanNextPage() is false.

What does the page label read?

Page, then table.state.pagination.pageIndex + 1, of table.getPageCount(). The index starts at zero, so the label adds one.

Is the page index stored outside the table?

No, only initialState is passed and the table keeps the page. Read it from table.state.pagination or listen with onPaginationChange to sync it with the URL.

What appears when there are no rows?

One cell spanning every column with No results.With these eight transactions it doesn't show.

Can I change pages from the keyboard?

Previous and Next are buttons, so Tab reaches them and Enter or Space activates them; a disabled one is skipped. For a jump to any page, see the numeric pagination example.