Skip to content

Pagination

Move through pages: numbers with ellipsis, previous and next, a page size select and a compact variant.

On this page
Used for
  • Run history pages
  • Ticket list paging
  • Search results
  • Audit log pages

Examples

Installation

npx knowns-ui@latest add pagination
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

page / defaultPage / onPageChange
number / number / (page) => void
Default - / 1
1-based current page. Controlled or not.
total + pageSize, or pageCount
number
Default - / 20
Item count and page size give the page count and the summary; or pass pageCount alone.
pageSizeOptions + onPageSizeChange
number[] / (size) => void
Adds a 'Per page' Select. Changing it goes back to page 1.
variant
"default" | "compact"
Default"default"
Compact shows Prev · Page 3 of 12 · Next.
siblings
number
Default1
Pages on each side of the current one. The row keeps the same length while you page.
showSummary / noun
boolean / string
Defaulttrue / "items"
"21–40 of 1,243 runs" when total is known.
size
"sm" | "md"
Default"md"
Button size (28 or 32px).

What it handles

  1. 01Builds the page list with pageRange: first and last pages, siblings around the current one, and an ellipsis for each gap, keeping the row the same length as you page.
  2. 02Gets the page count from total and pageSize, or takes pageCount directly, and clamps page to a real page.
  3. 03Writes a summary like 21-40 of 243 runs from total and noun, and says No runs when the total is zero.
  4. 04Adds a Per page Select from pageSizeOptions, which calls onPageSizeChange and returns to page 1.
  5. 05Switches to a compact Prev, Page 3 of 12, Next row through variant, and below 640px drops the button labels and the sibling pages.
  6. 06Disables Previous on the first page and Next on the last, and marks the current page with aria-current page.

States

First render
Nothing. The row paints with the current page marked
none
Page changes
The current page mark and the summary update at once
none
Page size changes
The page returns to 1 and the count recalculates at once
none
Narrow screen
Button labels and sibling pages drop out of the row
none

Works with

When to use

When to use

  • Moving through pages of results with a page size choice.

When not to use

  • Tables that already page or virtualise rows: use Data Table.

Using with AI

Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:

  • Add the Knowns UI Pagination to my app and wire it to my own data.
  • I need moving through pages of results with a page size choice. Set that up with the Knowns UI Pagination.
  • Which Pagination props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "pagination" }) and search_docs({ query: "pagination" }).

Need help?

Stuck on Pagination, or found something off? We read every message.