NavigationPagination
Searchastronomic.dev# Pagination
To move through a long list split over pages, like the journal.
Static: no JavaScript.
## Usage
```astro
import Pagination from "@astronomic-dev/ui/components/Pagination.astro";
```
## Examples
### Long list
```astro
---
import Pagination from "@astronomic-dev/ui/components/Pagination.astro";
const href = (n: number) => (n === 1 ? "#journal" : `#journal-page-${n}`);
---
<Pagination current={5} total={12} href={href} label="Journal pages" />
```
## Props
### Pagination
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `current` | `number` | None | Required. The current page, from 1. |
| `total` | `number` | None | Required. The number of pages. With 1 or fewer, nothing renders. |
| `href` | `(n: number) => string` | None | Required. The URL of page `n`. |
| `label` | `string` | `"Pagination"` | Accessible name of the navigation. |
| `previousLabel` | `string` | `"Previous"` | Text of the previous-page link. |
| `nextLabel` | `string` | `"Next"` | Text of the next-page link. |
| `pageLabel` | `(n: number) => string` | None | Accessible name of a page link. By default, "Page n". |
| `class` | `string` | None | More classes, merged with cn(), so yours win on conflicts. |
Any other attribute goes on the <nav>.
## Accessibility
- Renders a <nav> named by label (default "Pagination"), and nothing when there is only one page.
- Each number link is named by pageLabel, such as "Page 4", and the current page has aria-current="page".
- Previous and Next keep their text for screen readers on small screens, where only the arrows show.
- Gaps and the Previous or Next item on the first or last page are hidden from screen readers.
Pagination
FreeTo move through a long list split over pages, like the journal.
- File
- Pagination.astro
- Group
- Navigation
- Kind
- Static: no JavaScript
- Examples
- 1
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
Long list
Force statemain.astro
examples/pagination/main.astro
---
import Pagination from "@astronomic-dev/ui/components/Pagination.astro";
const href = (n: number) => (n === 1 ? "#journal" : `#journal-page-${n}`);
---
<Pagination current={5} total={12} href={href} label="Journal pages" />Minimal · Light