[ Navigation ]
Pagination
Lets users move between pages of results. It always shows the first and last page, the pages around the current one, and collapses the rest into ellipses.
2 examplesDark modeAccessible
Import#
import { Pagination } from 'reusify-ui';When to use#
- Long lists and tables split into pages: search results, orders, logs.
Examples#
Basic#
Pagination is controlled. Keep the current page in state (or in the URL) and update it in onChange.
Page 5 of 20
const [page, setPage] = useState(5);
<Pagination page={page} totalPages={20} onChange={setPage} />Sibling count & size#
siblingCount sets how many pages appear on each side of the current page.
Page 5 of 50
Page 5 of 10
<Pagination page={page} totalPages={50} onChange={setPage} siblingCount={2} />
<Pagination page={page} totalPages={10} onChange={setPage} size="sm" />API reference#
<Pagination />
| Prop | Type | Default | Description |
|---|---|---|---|
page* | number | - | Current page, starting at 1. |
totalPages* | number | - | Total number of pages. |
onChange* | (page: number) => void | - | Called with the new page. |
siblingCount | number | 1 | Pages shown on each side of the current page. |
size | 'sm' | 'md' | 'md' | Button size. |
page*-numberCurrent page, starting at 1.
totalPages*-numberTotal number of pages.
onChange*-(page: number) => voidCalled with the new page.
siblingCount1numberPages shown on each side of the current page.
size'md''sm' | 'md'Button size.
Accessibility#
- Wrapped in <nav aria-label="Pagination">.
- The current page has aria-current="page"; every button has a label like "Page 4" or "Next page".