Components / Navigation
Pagination
Page numbers with previous and next buttons. The current page is marked with aria-current.
import { Pagination } from "@stylhero/ui";
Example
Code
import { useState } from "react";
import { Pagination } from "@stylhero/ui";
function PaginationExample() {
const [page, setPage] = useState(3);
return <Pagination page={page} count={12} onPageChange={setPage} />;
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
count required |
number |
- | Total number of pages. |
onPageChange required |
(page: number) => void |
- | |
page required |
number |
- | Current page, starting at 1. |
siblings |
number |
1 |
Pages shown on each side of the current one. |
Also takes the HTML attributes of its root element (id, style, data-*, aria-*, event handlers…).
Keyboard
| Key | Does |
|---|---|
| Tab | Moves between the page buttons |
| Enter / Space | Goes to the page |
Accessibility
- A labelled
<nav>; the current page hasaria-current="page".
Generated from src/components/Pagination.tsx. Something wrong or missing? Open an issue.