# Pagination

Source: https://ecosphere.dev/docs/navigation/pagination (Ecosphere 1.5). Install `vue-ecosphere` for Vue 3 or `react-ecosphere` for React 18.2+/19: same components, props, markup and stylesheet.

The range and total, an optional rows-per-page or go-to-page control, and the page row — in a full bar, a plain row, or prev / position / next.

`import { EcoPagination } from "vue-ecosphere"`

## In a table footer

Say the range and the total, not just the page number. At most seven page buttons; the rest elide with a gap.

Vue (vue-ecosphere):

```vue
<div class="dtable">
  …table…
  <div class="dtable__foot">
    <EcoPagination v-model:page="page" v-model:page-size="size" :total="187"
      :page-sizes="[10, 25, 50, 100]" form="bar" prefix="Showing" />
  </div>
</div>
```

React (react-ecosphere):

```tsx
<div className="dtable">
  …table…
  <div className="dtable__foot">
    <EcoPagination page={page} onPageChange={setPage} pageSize={size} onPageSizeChange={setSize} total={187}
      pageSizes={[10, 25, 50, 100]} form="bar" prefix="Showing" />
  </div>
</div>
```

## Full row

Change the rows per page: the reader stays on the rows they were reading.

Vue (vue-ecosphere):

```vue
<EcoPagination v-model:page="page" v-model:page-size="size" :total="187"
  :page-sizes="[10, 25, 50, 100]" form="bar" />
```

React (react-ecosphere):

```tsx
<EcoPagination page={page} onPageChange={setPage} pageSize={size} onPageSizeChange={setSize} total={187}
  pageSizes={[10, 25, 50, 100]} form="bar" />
```

## Under a list

Prev and next disable at the ends rather than disappearing, so the row keeps its width.

Vue (vue-ecosphere):

```vue
<EcoPagination v-model:page="page" :page-size="12" :total="44" />
```

React (react-ecosphere):

```tsx
<EcoPagination page={page} onPageChange={setPage} pageSize={12} total={44} />
```

## Compact

For a list with no numbers worth showing.

Vue (vue-ecosphere):

```vue
<EcoPagination v-model:page="page" :page-size="25" :total="187" form="compact" />
```

React (react-ecosphere):

```tsx
<EcoPagination page={page} onPageChange={setPage} pageSize={25} total={187} form="compact" />
```

## With go-to-page

Type a page and press Enter.

Vue (vue-ecosphere):

```vue
<EcoPagination v-model:page="page" :page-size="25" :total="187" form="bar" jump />
```

React (react-ecosphere):

```tsx
<EcoPagination page={page} onPageChange={setPage} pageSize={25} total={187} form="bar" jump />
```

## API

Vue (vue-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `total` | `number` | — | Total number of items. |
| `v-model:page` | `number` | 1 | Current page, 1-based. Clamped to the page count. |
| `v-model:pageSize` | `number` | 25 | Items per page. Changing it keeps the first row the reader was on. |
| `form` | `"bar" \| "row" \| "compact"` | "row" | bar sits in a table or card footer; row under a list; compact is prev / position / next. |
| `pageSizes` | `number[]` | — | Shows the rows-per-page select (pager__size). Offer it only where the list is long enough. |
| `jump` | `boolean` | false | Shows the go-to-page field (pager__jump). |
| `prefix` | `string` | — | Text before the range, e.g. "Showing". |
| `sizeLabel / jumpLabel` | `string` | "Rows" / "Go to" | Labels of the two controls. |
| `#count` | `slot { from, to, total, page, pages }` | — | Replace the range text in pager__c. |

React (react-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `total` | `number` | — | Total number of items. |
| `page / onPageChange` | `number` | 1 | Current page, 1-based. Clamped to the page count. |
| `pageSize / onPageSizeChange` | `number` | 25 | Items per page. Changing it keeps the first row the reader was on. |
| `form` | `"bar" \| "row" \| "compact"` | "row" | bar sits in a table or card footer; row under a list; compact is prev / position / next. |
| `pageSizes` | `number[]` | — | Shows the rows-per-page select (pager__size). Offer it only where the list is long enough. |
| `jump` | `boolean` | false | Shows the go-to-page field (pager__jump). |
| `prefix` | `string` | — | Text before the range, e.g. "Showing". |
| `sizeLabel / jumpLabel` | `string` | "Rows" / "Go to" | Labels of the two controls. |
| `renderCount` | `(scope: { from, to, total, page, pages }) => ReactNode` | — | Replace the range text in pager__c. |
