Components
Pagination
NativeMoves between pages of a list, with the first, last and nearby pages always in reach.
Orders 61 to 80 of 240
Installation
npx nook-ui@latest add paginationPrompt
Paste this into your AI coding assistant. It adds this exact component, the same way the CLI does, and tells the assistant how to use it.
Short. For assistants that can run commands in your project.
Add the Nook "Pagination" component to this project, exactly as Nook ships it.
Moves between pages of a list, with the first, last and nearby pages always in reach.
Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add pagination`. It writes `components/ui/pagination.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/pagination.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:
```tsx
"use client";
import * as React from "react";
import { Pagination } from "@/components/ui/pagination";
export default function PaginationDefault() {
const [page, setPage] = React.useState(4);
return (
<div className="grid justify-items-center gap-2">
<Pagination page={page} count={12} onPageChange={setPage} aria-label="Orders pages" />
<p aria-live="polite" className="text-sm text-muted-foreground">Orders {(page - 1) * 20 + 1} to {page * 20} of 240</p>
</div>
);
}
```
API
- `Pagination`: The whole control.
- `page` (`number`): Current page, starting at 1.
- `count` (`number`): Total number of pages.
- `onPageChange` (`(page: number) => void`): Called with the new page.
- `siblings` (`number`, default 1): Pages shown on each side of the current one.
Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: Renders a nav landmark. Each page button says its page number and the current one has `aria-current="page"`. Previous and Next stay focusable at the ends and are marked disabled.
Done when the component renders like the example in light and dark mode and the project type-checks.Usage
"use client";
import * as React from "react";
import { Pagination } from "@/components/ui/pagination";
export default function PaginationDefault() {
const [page, setPage] = React.useState(4);
return (
<div className="grid justify-items-center gap-2">
<Pagination page={page} count={12} onPageChange={setPage} aria-label="Orders pages" />
<p aria-live="polite" className="text-sm text-muted-foreground">Orders {(page - 1) * 20 + 1} to {page * 20} of 240</p>
</div>
);
}Examples
Few pages
Many pages
Page 48 of 120
In a list footer
- Order #4800
- Order #4801
- Order #4802
- Order #4803
- Order #4804
Page 1 of 5
On the last page
Props
Pagination
The whole control.
| Prop | Type | Default | Description |
|---|---|---|---|
| page | number | – | Current page, starting at 1. |
| count | number | – | Total number of pages. |
| onPageChange | (page: number) => void | – | Called with the new page. |
| siblings | number | 1 | Pages shown on each side of the current one. |
Accessibility
Renders a nav landmark. Each page button says its page number and the current one has `aria-current="page"`. Previous and Next stay focusable at the ends and are marked disabled.
Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.