---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Pagination

The row of page numbers with previous and next under a long table or list, to move between its pages, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `Pagination`.

## Try it

Turn the pages of twenty-three orders, two a page, by number or with Previous and Next; the ends switch off at the first and the last page, and a gap stands for the pages not shown, the row seven places on every page.

The orders are our own sample rows in the page; nothing is fetched per page.

## When to use

- The row of page numbers with previous and next under a long table or list, to move between its pages.
- Also called: pager.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Pagination on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-pagination.json --yes
```

```text
Add the Goop Pagination to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import {
  Pagination, PaginationContent, PaginationList, PaginationItem, PaginationLink, PaginationPrevious, PaginationNext, PaginationEllipsis, PaginationPages, pageRange,
} from '@/components/ui/goop/pagination';
import { useState } from 'react';

function NotesPages() {
  const [page, setPage] = useState(1);
  return (
    <>
      <Pagination aria-label="Pages of notes">
        <PaginationPages page={page} pageCount={12} href={(n) => `?page=${n}`} onPageChange={setPage} />
      </Pagination>
      {/* a hand-picked run of pages, written with the parts */}
      <Pagination>
        <PaginationContent>
          <PaginationItem>
            <PaginationPrevious href="?page=2" />
          </PaginationItem>
          <PaginationItem>
            <PaginationList>
              <PaginationItem>
                <PaginationLink href="?page=1">1</PaginationLink>
              </PaginationItem>
              <PaginationItem>
                <PaginationEllipsis />
              </PaginationItem>
              <PaginationItem>
                <PaginationLink href="?page=3" isActive>
                  3
                </PaginationLink>
              </PaginationItem>
              <PaginationItem>
                <PaginationLink href="?page=4">4</PaginationLink>
              </PaginationItem>
            </PaginationList>
          </PaginationItem>
          <PaginationItem>
            <PaginationNext href="?page=4" />
          </PaginationItem>
        </PaginationContent>
      </Pagination>
    </>
  );
}
```

- Fits: list (its recipe).
- PaginationPages: Every page is a real link to `href(page)`; with `onPageChange` a plain click turns the page in place instead and the caller sets `page`. For a hand-picked run of pages write the parts: `PaginationContent`, `PaginationList`, `PaginationLink`.
- height, width, padding, gap, text: add no class for these.

## API reference

### Options

- `Defaults: aria-label = 'Pagination'`

### Parts

- `PaginationContent` — The row in Pagination; PaginationPrevious, a PaginationList, then PaginationNext, each in an item
- `PaginationList` — The run of pages and gaps, a list of its own inside one item of the row, with the same gap between its places
- `PaginationItem` — One place in the row or in its run
- `PaginationLink` — A link to one page by its number, in a PaginationItem; mark the page shown with isActive; isActive?: boolean = false — This is the page shown: `aria-current="page"`, and the pill's current look; pageLabel?: string — The word said before the page's number in its spoken name ("Page" 3, the default), the caller's to translate; also takes href?: string
- `PaginationPrevious` — The link to the page before, as the theme's quiet 28 px link; label?: string = 'Previous' — The link's words and spoken name; disabled?: boolean = false — No page that way: the link stays, dimmed, but leads nowhere and takes no tab stop; also takes href?: string
- `PaginationNext` — The link to the page after, as the theme's quiet 28 px link; label?: string = 'Next' — The link's words and spoken name; disabled?: boolean = false — No page that way: the link stays, dimmed, but leads nowhere and takes no tab stop; also takes href?: string
- `PaginationEllipsis` — The pages left out; label?: string = 'More pages' — The dots' spoken name
- `PaginationPages` — A ready pagination row that works out its own pages; its props: pagination--pages.md

- pageRange
- data-slot values (to select a part by): pagination, pagination-content, pagination-ellipsis, pagination-item, pagination-link, pagination-list, pagination-next, pagination-previous

### PaginationPages

A ready pagination row that works out its own pages.

```tsx
import { PaginationPages } from '@/components/ui/goop/pagination';
```

### Options

- page: number — The page shown, from 1.
- pageCount: number — How many pages the list has.
- siblings?: number = 1 — Pages shown either side of the page shown.
- boundaries?: number = 1 — Pages always shown at each end.
- href: (page: number) => string — The address of a page by its number (`(n) => "?page=" + n`): every page, previous and next link there.
- onPageChange?: (page: number) => void — Called with the page a plain click asks for; the click's own navigation is stopped.
- pageLabel?: string — The word said before each page's number ("Page" 3, the default), the caller's to translate.
- previousLabel?: string = 'Previous' — Previous's words, the caller's to translate.
- nextLabel?: string = 'Next' — Next's words, the caller's to translate.
- gapLabel?: string = 'More pages' — What the dots stand for, said to a reader.

## Keyboard

- Tab: move to the next link

## Accessibility

- The part itself answers the keys above.
- disabled: the attribute aria-disabled

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

## Related

- [Accordion](/themes/trail/components/accordion): Stacked sections that each open and close their own content, for a FAQ or a long page of options.
- [Collapsible](/themes/trail/components/collapsible): One trigger that shows and hides the content right below it, such as more options.
- [Contents nav](/themes/trail/components/contents-nav): A table of contents for a long reading page (an article, a guide, a help page), each link jumping to a section.
- [Navigation menu](/themes/trail/components/navigation-menu): A site's header menu: a row of links and triggers, each trigger opening a panel of links.
