Move through pages: numbers with ellipsis, previous and next, a page size select and a compact variant.
Used for
- Run history pages
- Ticket list paging
- Search results
- Audit log pages
Examples
Installation
npx knowns-ui@latest add paginationFor Claude Code, Cursor or Codex: installs it and wires the props to your own data.
Paste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install prompt
Install Pagination from Knowns UI into this project. Work step by step, show me each change, and ask before you edit files outside this project.
Context: Knowns UI (https://ui.knowns.dev) is a shadcn registry. Items land in the project as source files. Docs: https://ui.knowns.dev/docs/pagination
1. Check the project first. Stop and tell me if any of these is missing:
- React 19 and Tailwind CSS v4.
- A components.json at the project root. If there is none, ask me before running `npx knowns-ui@latest init --no-key` (it runs shadcn init when needed, then adds the registries).
2. Run:
```bash
npx knowns-ui@latest add pagination
```
It writes these files:
- lib/knowns/run.ts
- lib/knowns/json.tsx
- lib/knowns/status.ts
- lib/knowns/tone.ts
- lib/knowns/types.ts
- lib/knowns/use-abortable.ts
- lib/knowns/utils.ts
- components/ui/knowns/spinner.tsx
- components/ui/knowns/button.tsx
- components/ui/knowns/kbd.tsx
- components/ui/knowns/field-class.ts
- components/ui/knowns/textarea.tsx
- components/ui/knowns/chat-composer/use-autosize.ts
- lib/knowns/motion.tsx
- lib/knowns/motion-utils.ts
- components/ui/knowns/use-floating.ts
- components/ui/knowns/tooltip.tsx
- components/ui/knowns/tooltip-utils.ts
- components/ui/knowns/input.tsx
- components/ui/knowns/select.tsx
- components/ui/knowns/pagination.tsx
and installs these npm packages: clsx@^2.1.1, tailwind-merge@^3.7.0, class-variance-authority@^0.7.1.
3. While it runs:
- It also adds a few @keyframes (all named kn-*) to the global CSS file (globals.css or the file components.json points at). Let it: they only add animations.
- If it asks to overwrite files under lib/knowns/: these are shared by every Knowns UI item. List them, say whether I changed them (check git), and ask me before you answer.
- If it asks to overwrite any other file, show me the diff and ask me.
4. Verify:
- Every file in the list above exists.
- The project type-checks (for example `npx tsc --noEmit`) and the dev build has no new errors.
5. Use it: follow the examples and props on https://ui.knowns.dev/docs/pagination, and ask me if anything about my data is unclear.
If the Knowns UI MCP server is connected (https://ui.knowns.dev/docs/ai-and-mcp), use get_component({ name: "pagination" }) or search_docs for details.
Finish with a short summary: the files you added or changed, the packages you installed, and anything I still need to do.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- Default
1 - Pages on each side of the current one. The row keeps the same length while you page.
- showSummary / noun
boolean / string- Default
true / "items" - "21–40 of 1,243 runs" when total is known.
- size
"sm"|"md"- Default
"md" - Button size (28 or 32px).
| Prop | Type | Default | Description |
|---|---|---|---|
| page / defaultPage / onPageChange | number / number / (page) => void | - / 1 | 1-based current page. Controlled or not. |
| total + pageSize, or pageCount | number | - / 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" | Compact shows Prev · Page 3 of 12 · Next. |
| siblings | number | 1 | Pages on each side of the current one. The row keeps the same length while you page. |
| showSummary / noun | boolean / string | true / "items" | "21–40 of 1,243 runs" when total is known. |
| size | "sm" | "md" | "md" | Button size (28 or 32px). |
What it handles
- 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.
- 02Gets the page count from total and pageSize, or takes pageCount directly, and clamps page to a real page.
- 03Writes a summary like 21-40 of 243 runs from total and noun, and says No runs when the total is zero.
- 04Adds a Per page Select from pageSizeOptions, which calls onPageSizeChange and returns to page 1.
- 05Switches to a compact Prev, Page 3 of 12, Next row through variant, and below 640px drops the button labels and the sibling pages.
- 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
| State | What moves | Timing |
|---|---|---|
| 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" }).