Pagination
NavigationPages of a list: <Pagination.Root> (count, perPage, bind:page, siblingCount) is a navigation landmark (label) that draws previous, the pages (the current one marked, gaps as an ellipsis) and next. The pages are buttons that change page; load the page's data when it changes. To draw it yourself, its children snippet gets the pages: a Pagination.Content list of Pagination.Items, each a Pagination.Page or a Pagination.Ellipsis, between a Pagination.PrevButton and a Pagination.NextButton.
import { Pagination } from '@limerdev/zest'; Button.Examples
Basic
240 orders, 20 a page. Load the page's data when page changes.
Orders 1–20 of 240
<script lang="ts">
import { Pagination } from '@limerdev/zest';
let page = $state(1);
</script>
<div class="grid gap-3">
<Pagination.Root count={240} perPage={20} bind:page />
<p class="text-center text-sm text-muted">Orders {(page - 1) * 20 + 1}–{page * 20} of 240</p>
</div> Your own layout
The children snippet gets the pages and the range shown, to draw your own layout.
<script lang="ts">
import { Pagination } from '@limerdev/zest';
let page = $state(1);
</script>
<Pagination.Root count={240} perPage={20} bind:page>
{#snippet children({ range })}
<Pagination.Content>
<Pagination.Item><Pagination.PrevButton /></Pagination.Item>
<Pagination.Item>
<span class="px-3 text-sm text-muted">{range.start}–{range.end} of 240</span>
</Pagination.Item>
<Pagination.Item><Pagination.NextButton /></Pagination.Item>
</Pagination.Content>
{/snippet}
</Pagination.Root> Props
Every part also takes class (merged over its defaults), ref (bindable: the element), children, and child (a snippet that
renders your own element, with props to spread on it).
Pagination.Root
| Prop | Type | Default | Description |
|---|---|---|---|
| count required | number | – | The total number of items to be paginated. |
| label | string | the Config's `strings.pagination`, else 'Pagination' | The navigation landmark's name. |
| loop | boolean | false | Whether keyboard navigation should loop back to the first or last page trigger when reaching either end. |
| onPageChange | OnChangeFn<number> | – | A callback function called when the page changes. |
| orientation | "horizontal" | "vertical" | "horizontal" | The orientation of the pagination component. Used to determine how keyboard navigation should work between pages. |
| page bindable | number | 1 | The current page number. |
| perPage | number | 10 | The number of items per page. |
| siblingCount | number | 1 | The number of visible items before and after the current page. |
Pagination.Content
No props of its own beyond the common ones.
Pagination.Item
No props of its own beyond the common ones.
Pagination.Page
| Prop | Type | Default | Description |
|---|---|---|---|
| page required | Page | – |
Pagination.PrevButton
No props of its own beyond the common ones.
Pagination.NextButton
No props of its own beyond the common ones.
Pagination.Ellipsis
| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | the Config's `strings.morePages`, else 'More pages' | What the ellipsis stands for, for screen readers. |