# Odometer pager

Pagination whose numbers roll past like an odometer.

Also called: animated pagination, rolling numbers pagination.

Example: Page numbers that roll. Jump from page 5 to 19 and the middle numbers roll past like wheels, blurred by their speed, while the pill stretches over. Preview: https://chatcn.dev/preview/odometer-pager-demo

Jump far, by typing a page or clicking the end, and the three middle numbers roll past like wheels, staggered left to right, blurred by their own speed, settling a hair past the mark and back. The dark pill stretches toward the new page, its leading edge first, and squashes with the reel it rides on; the numbers inside it are a second, inverted copy clipped to the pill, so they flip colour cleanly as it passes over.

## Installation

```bash
npx shadcn@latest add https://chatcn.dev/r/odometer-pager.json
```

## Usage

```tsx
import { OdometerPager } from "@/components/ui/chatcn/odometer-pager"

<OdometerPager page={page} pageCount={24} onPageChange={setPage} />
```

Made for seven pages or more, where the middle window moves.

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `page` / `onPageChange` | `number` | 1 based |
| `pageCount` | `number` |  |
| `goTo` | `boolean` | The Go to field; default true |

## Keyboard

| Key | Action |
| --- | --- |
| `Enter` in Go to | Jump to that page |

## Accessibility

- A labelled nav with real buttons; the current page carries `aria-current`.

## Motion

- Reels roll 420 ms for a step and up to about a second for a far jump, 55 ms apart. Reduced motion: numbers and pill jump.

Source: https://chatcn.dev/docs/components/odometer-pager