---
title: "Pagination"
description: "Pagination component - page navigation controls with prev/next and page numbers."
slug: "pagination"
---

import { DocPage, PageHeader, SkillPanel, SourceFiles, SourceNote, StatesSection, CodeBlock, Demo, DemoCode, ChangelogEntries, ArchBody, StatsClaim, StatsCards, PageOverlay, DocText, DocLink, H2, SkillField, SkillText, SkillRow, SkillGrid, Variant, ApiPill, Dim, CodeCard, TableCard, ApiSection } from "../../lib/components/index";

<DocPage meta={meta}>

<PageHeader slug="pagination" title="Pagination" component="pagination">
  Page navigation with previous/next links and page numbers.
</PageHeader>

<SkillPanel component="pagination">
  <SkillField label="Native basis">
<SkillText><code>&lt;nav&gt;</code> + links for page navigation.</SkillText>
  </SkillField>

  <SkillField label="Web Platform APIs">
<SkillRow>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/nav" title="navigation landmark"><code>&lt;nav&gt;</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current" title="identifies the active page"><code>aria-current="page"</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible" title="keyboard-only focus ring"><code>:focus-visible</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion" title="suppresses hover transitions"><code>prefers-reduced-motion</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-contrast" title="thickens borders for high-contrast"><code>prefers-contrast</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/CSS/@media/forced-colors" title="maps to system colors"><code>forced-colors</code></ApiPill>
  </SkillRow>
  </SkillField>

  <SkillField label="Classes">
<SkillRow>
    <code>.pagination</code>
    <code>.pagination-list</code>
    <code>.pagination-link</code>
    <code>.pagination-prev</code>
    <code>.pagination-next</code>
    <code>.pagination-active</code>
    <code>.pagination-ellipsis</code>
  </SkillRow>
  </SkillField>

  <SkillField label="Data attributes">
<SkillText><code>data-variant</code> (<code>outline</code>, <code>joined</code>), <code>data-layout="split"</code>, <code>data-size</code> (<code>xs</code> ... <code>xl</code>), <code>data-density</code>; data-driven: <code>data-active-page</code>, <code>data-min-page</code>, <code>data-max-page</code>, <code>data-page-display-count</code>.</SkillText>
  </SkillField>
</SkillPanel>

```html example label="Default" hint="Data-driven: declare data-active-page / data-min-page / data-max-page / data-page-display-count and the component renders the page window, ellipses and prev/next disabled states itself."
<nav
  class="pagination"
  aria-label="Pagination"
  data-active-page="5"
  data-min-page="1"
  data-max-page="10"
  data-page-display-count="3"
>
  <ul class="pagination-list">
    <li>
      <a class="pagination-prev" href="#" aria-label="Go to previous page"
        ><svg
          aria-hidden="true"
          width="16"
          height="16"
          viewBox="0 0 24 24"
          fill="none"
          stroke="currentColor"
          stroke-width="2"
          stroke-linecap="round"
          stroke-linejoin="round"
        >
          <path d="m15 18-6-6 6-6" />
        </svg>
        Previous</a
      >
    </li>
    <li>
      <a class="pagination-next" href="#" aria-label="Go to next page"
        >Next
        <svg
          aria-hidden="true"
          width="16"
          height="16"
          viewBox="0 0 24 24"
          fill="none"
          stroke="currentColor"
          stroke-width="2"
          stroke-linecap="round"
          stroke-linejoin="round"
        >
          <path d="m9 18 6-6-6-6" /></svg
      ></a>
    </li>
  </ul>
</nav>
```

```html example label="Icons only" hint="Compact pagination with just chevron arrows - useful alongside a 'rows per page' selector."
<nav class="pagination" aria-label="Pagination">
  <ul class="pagination-list">
    <li>
      <a class="pagination-prev" href="#" aria-label="Go to previous page" aria-disabled="true">
        <svg
          aria-hidden="true"
          width="16"
          height="16"
          viewBox="0 0 24 24"
          fill="none"
          stroke="currentColor"
          stroke-width="2"
          stroke-linecap="round"
          stroke-linejoin="round"
        >
          <path d="m15 18-6-6 6-6" />
        </svg>
      </a>
    </li>
    <li>
      <span style="font-size: 0.875rem; color: var(--muted-foreground); padding: 0 0.5rem">Page 1 of 10</span>
    </li>
    <li>
      <a class="pagination-next" href="#" aria-label="Go to next page">
        <svg
          aria-hidden="true"
          width="16"
          height="16"
          viewBox="0 0 24 24"
          fill="none"
          stroke="currentColor"
          stroke-width="2"
          stroke-linecap="round"
          stroke-linejoin="round"
        >
          <path d="m9 18 6-6-6-6" />
        </svg>
      </a>
    </li>
  </ul>
</nav>
```

```html example label="Simple" hint="Page numbers only - no previous/next text labels."
<nav class="pagination" aria-label="Pagination">
  <ul class="pagination-list">
    <li><a class="pagination-link" href="#">1</a></li>
    <li><a class="pagination-link pagination-active" href="#" aria-current="page">2</a></li>
    <li><a class="pagination-link" href="#">3</a></li>
    <li><a class="pagination-link" href="#">4</a></li>
    <li><a class="pagination-link" href="#">5</a></li>
  </ul>
</nav>
```

```html example label="Outline" hint="data-variant='outline' - every cell a bordered button; the active page fills with the accent surface so it still stands out."
<nav class="pagination" data-variant="outline" aria-label="Pagination outline">
  <ul class="pagination-list">
    <li
      ><a class="pagination-prev" href="#" aria-label="Go to previous page"
        ><svg
          aria-hidden="true"
          width="16"
          height="16"
          viewBox="0 0 24 24"
          fill="none"
          stroke="currentColor"
          stroke-width="2"
          stroke-linecap="round"
          stroke-linejoin="round"
        >
          <path d="m15 18-6-6 6-6" />
        </svg>
        Previous</a
      ></li
    >
    <li><a class="pagination-link" href="#">1</a></li>
    <li><a class="pagination-link pagination-active" href="#" aria-current="page">2</a></li>
    <li><a class="pagination-link" href="#">3</a></li>
    <li><span class="pagination-ellipsis" aria-hidden="true">&hellip;</span></li>
    <li><a class="pagination-link" href="#">10</a></li>
    <li
      ><a class="pagination-next" href="#" aria-label="Go to next page"
        >Next
        <svg
          aria-hidden="true"
          width="16"
          height="16"
          viewBox="0 0 24 24"
          fill="none"
          stroke="currentColor"
          stroke-width="2"
          stroke-linecap="round"
          stroke-linejoin="round"
        >
          <path d="m9 18 6-6-6-6" /></svg></a
    ></li>
  </ul>
</nav>
```

```html example label="Joined" hint="data-variant='joined' - one segmented bar: neighbours share a border, only the outer corners round (logical radii - mirrors in RTL), the ellipsis joins the chain."
<nav class="pagination" data-variant="joined" aria-label="Pagination joined">
  <ul class="pagination-list">
    <li
      ><a class="pagination-prev" href="#" aria-label="Go to previous page"
        ><svg
          aria-hidden="true"
          width="16"
          height="16"
          viewBox="0 0 24 24"
          fill="none"
          stroke="currentColor"
          stroke-width="2"
          stroke-linecap="round"
          stroke-linejoin="round"
        >
          <path d="m15 18-6-6 6-6" />
        </svg>
        Previous</a
      ></li
    >
    <li><a class="pagination-link" href="#">1</a></li>
    <li><a class="pagination-link pagination-active" href="#" aria-current="page">2</a></li>
    <li><a class="pagination-link" href="#">3</a></li>
    <li><span class="pagination-ellipsis" aria-hidden="true">&hellip;</span></li>
    <li><a class="pagination-link" href="#">10</a></li>
    <li
      ><a class="pagination-next" href="#" aria-label="Go to next page"
        >Next
        <svg
          aria-hidden="true"
          width="16"
          height="16"
          viewBox="0 0 24 24"
          fill="none"
          stroke="currentColor"
          stroke-width="2"
          stroke-linecap="round"
          stroke-linejoin="round"
        >
          <path d="m9 18 6-6-6-6" /></svg></a
    ></li>
  </ul>
</nav>
```

```html example label="Disabled at boundaries" hint="Previous is disabled on the first page; next is disabled on the last page." previewStyle="display: flex; flex-direction: column; gap: 1.5rem;"
<!-- First page: previous disabled -->
<a class="pagination-prev" href="#" aria-label="Go to previous page" aria-disabled="true">…</a>

<!-- Last page: next disabled -->
<a class="pagination-next" href="#" aria-label="Go to next page" aria-disabled="true">…</a>
```

```html example label="Previous / next (split)" hint="data-layout='split' - two equal columns across the container, the pager under an article; combines with any variant. aria-disabled='true' alone mutes a boundary link."
<div class="flex flex-col gap-4 w-full">
  <nav class="pagination" data-layout="split" data-variant="outline" aria-label="Article pages">
    <ul class="pagination-list">
      <li
        ><a class="pagination-prev" href="#" aria-label="Go to previous page" aria-disabled="true"
          ><svg
            aria-hidden="true"
            width="16"
            height="16"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="m15 18-6-6 6-6" />
          </svg>
          Previous</a
        ></li
      >
      <li
        ><a class="pagination-next" href="#" aria-label="Go to next page"
          >Next
          <svg
            aria-hidden="true"
            width="16"
            height="16"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="m9 18 6-6-6-6" /></svg></a
      ></li>
    </ul>
  </nav>
  <nav class="pagination" data-layout="split" data-variant="joined" data-size="lg" aria-label="Chapters">
    <ul class="pagination-list">
      <li
        ><a class="pagination-prev" href="#" aria-label="Previous chapter"
          ><svg
            aria-hidden="true"
            width="16"
            height="16"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="m15 18-6-6 6-6" />
          </svg>
          Chapter 3</a
        ></li
      >
      <li
        ><a class="pagination-next" href="#" aria-label="Next chapter"
          >Chapter 5
          <svg
            aria-hidden="true"
            width="16"
            height="16"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            stroke-width="2"
            stroke-linecap="round"
            stroke-linejoin="round"
          >
            <path d="m9 18 6-6-6-6" /></svg></a
      ></li>
    </ul>
  </nav>
</div>
```

```html example label="Sizes" hint="Set data-size on the .pagination nav; every cell scales - the default equals md."
<div class="flex items-center gap-4 mb-3">
  <span class="demo-label demo-label-w5">Extra small</span>
  <nav class="pagination" data-size="xs" aria-label="Pagination xs"
    ><ol class="pagination-list"
      ><li><a class="pagination-link" href="#">1</a></li
      ><li><a class="pagination-link pagination-active" aria-current="page" href="#">2</a></li
      ><li><a class="pagination-link" href="#">3</a></li></ol
    ></nav
  >
</div>
<div class="flex items-center gap-4 mb-3">
  <span class="demo-label demo-label-w5">Small</span>
  <nav class="pagination" data-size="sm" aria-label="Pagination sm"
    ><ol class="pagination-list"
      ><li><a class="pagination-link" href="#">1</a></li
      ><li><a class="pagination-link pagination-active" aria-current="page" href="#">2</a></li
      ><li><a class="pagination-link" href="#">3</a></li></ol
    ></nav
  >
</div>
<div class="flex items-center gap-4 mb-3">
  <span class="demo-label demo-label-w5">Medium</span>
  <nav class="pagination" data-size="md" aria-label="Pagination md"
    ><ol class="pagination-list"
      ><li><a class="pagination-link" href="#">1</a></li
      ><li><a class="pagination-link pagination-active" aria-current="page" href="#">2</a></li
      ><li><a class="pagination-link" href="#">3</a></li></ol
    ></nav
  >
</div>
<div class="flex items-center gap-4 mb-3">
  <span class="demo-label demo-label-w5">Large</span>
  <nav class="pagination" data-size="lg" aria-label="Pagination lg"
    ><ol class="pagination-list"
      ><li><a class="pagination-link" href="#">1</a></li
      ><li><a class="pagination-link pagination-active" aria-current="page" href="#">2</a></li
      ><li><a class="pagination-link" href="#">3</a></li></ol
    ></nav
  >
</div>
<div class="flex items-center gap-4 mb-3">
  <span class="demo-label demo-label-w5">Extra large</span>
  <nav class="pagination" data-size="xl" aria-label="Pagination xl"
    ><ol class="pagination-list"
      ><li><a class="pagination-link" href="#">1</a></li
      ><li><a class="pagination-link pagination-active" aria-current="page" href="#">2</a></li
      ><li><a class="pagination-link" href="#">3</a></li></ol
    ></nav
  >
</div>
```

```html example label="Density" hint="Set data-density on the component root to scale its internal whitespace. A whitespace policy, not a zoom: only gaps and padding scale (ratio 0.75 / 1 / 1.25), typography and fixed dimensions stay identical. comfortable matches the unsized default."
<div class="flex items-center gap-4 mb-3">
  <span class="demo-label demo-label-w75">Compact</span>
  <nav class="pagination" data-density="compact" aria-label="Pagination compact"
    ><ol class="pagination-list"
      ><li><a class="pagination-link" href="#">1</a></li
      ><li><a class="pagination-link pagination-active" aria-current="page" href="#">2</a></li
      ><li><a class="pagination-link" href="#">3</a></li></ol
    ></nav
  >
</div>
<div class="flex items-center gap-4 mb-3">
  <span class="demo-label demo-label-w75">Comfortable</span>
  <nav class="pagination" data-density="comfortable" aria-label="Pagination comfortable"
    ><ol class="pagination-list"
      ><li><a class="pagination-link" href="#">1</a></li
      ><li><a class="pagination-link pagination-active" aria-current="page" href="#">2</a></li
      ><li><a class="pagination-link" href="#">3</a></li></ol
    ></nav
  >
</div>
<div class="flex items-center gap-4 mb-3">
  <span class="demo-label demo-label-w75">Spacious</span>
  <nav class="pagination" data-density="spacious" aria-label="Pagination spacious"
    ><ol class="pagination-list"
      ><li><a class="pagination-link" href="#">1</a></li
      ><li><a class="pagination-link pagination-active" aria-current="page" href="#">2</a></li
      ><li><a class="pagination-link" href="#">3</a></li></ol
    ></nav
  >
</div>
```

<StatesSection>
  <p class="text-sm text-muted-foreground m-0 mb-3">The runtime declares the single <code>default</code> state; the editable contract below lives on the nav/list as <code>data-*</code> attributes, driven per instance through the bound <code>api</code> or the State tab:</p>
  <p class="text-sm text-muted-foreground">Machine contract - verified against <a class="link" href="../schemas/pagination.schema.json"><code>pagination.schema.json</code></a> by <code>bun run verify</code>:</p>

```states
| State | Type | Values | Default | Description |
| --- | --- | --- | --- | --- |
| `activePage` | `number` | `—` | `3` | Current page - rendered `aria-current="page"`; changed by links, `next()`/`prev()` actions or the panel. |
| `minPage` | `number` | `—` | `1` | First selectable page (panel edits re-render the links). |
| `maxPage` | `number` | `—` | `20` | Last selectable page (panel edits re-render the links). |
| `pageDisplayCount` | `number` | `—` | `3` | How many page links the window shows around the active page (rest collapse to ellipsis). |
| `size` | `enum` | `xs`, `sm`, `md`, `lg`, `xl` | `"md"` | Link scale (display sizes). |
```

</StatesSection>

<ApiSection component="pagination" />

<SourceFiles component="pagination" section="js">
  <SourceNote for="js">The optional progressive-enhancement layer: a data-driven nav (<code>data-active-page</code> + <code>data-min-page</code> / <code>data-max-page</code> / <code>data-page-display-count</code>) gets its link window keyed-morphed around the active page, prev/next stay honest, and clicks plus the <code>pagination-next</code>/<code>pagination-prev</code> action events step the page. Authored markup without those attributes renders exactly as written.</SourceNote>
</SourceFiles>

<SourceFiles component="pagination" section="css">
  <SourceNote for="css">Styles for the pagination component. Uses design tokens for colors, spacing, and radius.</SourceNote>
</SourceFiles>

</DocPage>
