# Pagination

Pagination is a neobrutalist React component from Cruise UI. Page numbers with Previous / Next; compacts to "Page 3 of 12" on phones.

Install (with the @cruiseui registry in components.json, see Installation):

```bash
npx shadcn@latest add @cruiseui/pagination
```

Import: `import { CruisePagination, cruisePageItems } from "@/components/cruise/pagination";`

## When to use

Long lists split into pages: orders, search results.

## When not to

Feeds (a "Load more" button is simpler).

## Example (React)

```tsx
"use client";

import { useState } from "react";
import { CruisePagination } from "@/components/cruise/pagination";

export default function PaginationExample() {
  const [page, setPage] = useState(5);
  return <CruisePagination page={page} pageCount={20} onPageChange={setPage} />;
}
```

## HTML

Needs theme.css (https://cruiseui.dev/theme.css).

```html
<nav class="pagination" aria-label="Pagination">
  <ul>
    <li><a class="brutal page-btn" href="?page=4" aria-label="Previous page">
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" aria-hidden="true"><path d="m15 18-6-6 6-6"/></svg>
      <span class="page-step-text">Previous</span></a></li>
    <li data-page><a class="brutal page-btn" href="?page=1" aria-label="Page 1">1</a></li>
    <li data-page><span class="page-gap" aria-hidden="true">…</span></li>
    <li data-page><a class="brutal page-btn" href="?page=4" aria-label="Page 4">4</a></li>
    <li data-page><a class="brutal page-btn on-primary" aria-current="page" aria-label="Page 5">5</a></li>
    <li data-page><a class="brutal page-btn" href="?page=6" aria-label="Page 6">6</a></li>
    <li data-page><span class="page-gap" aria-hidden="true">…</span></li>
    <li data-page><a class="brutal page-btn" href="?page=20" aria-label="Page 20">20</a></li>
    <li class="page-compact">Page 5 of 20</li>
    <li><a class="brutal page-btn" href="?page=6" aria-label="Next page">
      <span class="page-step-text">Next</span>
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" aria-hidden="true"><path d="m9 18 6-6-6-6"/></svg></a></li>
  </ul>
</nav>
<!-- On page 1, Previous has no href: <a class="brutal page-btn" aria-disabled="true" aria-label="Previous page"> -->
```

## Props: CruisePagination

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `page` | `number` | — | The current page (1-based). |
| `pageCount` | `number` | — | — |
| `onPageChange` | `(page: number) => void` | — | — |
| `className?` | `string` | — | — |

## Accessibility

- <nav aria-label="Pagination">; the current page has aria-current="page".
- Previous / Next keep their aria-label when the text hides on small screens.
