# Pagination

> Move between pages of a long list or table.

- Category: Navigation
- Import: `import { Pagination } from "@sagui/ui";`
- Page: /components/pagination

```tsx
import { useState } from "react";
import { Pagination } from "@sagui/ui";

export function Hero() {
  const [page, setPage] = useState(1);
  return (
    <Pagination page={page} pageCount={24} onPageChange={setPage} summary={`Showing ${(page - 1) * 20 + 1}–${page * 20} of 468`} className="w-full" />
  );
}
```

## When to use

- Under a data table with more than one page of results.

## When not to use

- Use infinite loading for feeds, and Stepper for steps.

## Installation

Install the package and import the styles once. The [installation guide](/docs/installation) covers the Tailwind setup.

```bash
npm install @sagui/ui
```

## Usage

```tsx
import { Pagination } from "@sagui/ui";

<Pagination page={page} pageCount={24} onPageChange={setPage} summary="Showing 1–20 of 468" />
```

## Examples

### Compact

```tsx
import { useState } from "react";
import { Pagination } from "@sagui/ui";

export function Compact() {
  const [page, setPage] = useState(1);
  return (
    <Pagination page={page} pageCount={24} onPageChange={setPage} layout="compact" />
  );
}
```

## Accessibility

- Renders a `nav` labeled “Pagination”. The current page has `aria-current="page"`.
- Gaps are hidden from screen readers, and every page button has a full label.
