# Pagination

> Moves between pages of a long list. Controlled, with buttons or real links.

Status: beta. Category: Navigation.

```ts
import { Pagination } from '@glyphui/ui'
```

Exports: `Pagination`, `paginationRange`, `paginationStyles`.

## Notes

- The number of items stays constant while paging, so the control never jumps in width.
- The current page is marked with aria-current="page"; ellipses are hidden from screen readers.

## Example: Controlled

```tsx
import { Pagination, Text } from '@glyphui/ui'
import { useState } from 'react'

export default function Example() {
  const [page, setPage] = useState(6)
  return (
    <div className="grid justify-items-start gap-3">
      <Pagination page={page} pageCount={20} onPageChange={setPage} />
      <Text size="small" tone="muted">
        Page {page} of 20
      </Text>
    </div>
  )
}
```

## Example: As links

getHref renders links, so each page has a URL and works without JavaScript.

```tsx
import { Pagination } from '@glyphui/ui'

export default function Example() {
  return (
    <Pagination
      page={3}
      pageCount={8}
      size="sm"
      showEdges={false}
      getHref={(page) => `?page=${page}`}
    />
  )
}
```

## Example: Range helper

paginationRange is exported for custom pagers.

```tsx
import { paginationRange } from '@glyphui/ui'

export default function Example() {
  return (
    <pre className="font-mono text-small text-muted-foreground">
      {[1, 6, 20]
        .map((page) => `page ${page}: ${JSON.stringify(paginationRange(page, 20))}`)
        .join('\n')}
    </pre>
  )
}
```

Live page: https://glyphui.xyz/components/pagination
