Navigation
Pagination
Page navigation with previous/next buttons, boundary and sibling pages and ellipses.
import { Pagination } from "datui";Playground
<Pagination totalPages={20} siblingCount={1} boundaryCount={1} navigationButtonsStyle="icon" />Examples
Controlled
siblingCount and boundaryCount control how many pages are shown around the current one and at the ends.
Links and captions
renderPageButton/renderNavigationButton render your own elements, e.g. router links.
Accessibility
- A
<nav>labelled by a visually hidden heading (navigationLabel, default "Pages"). - Page buttons are named "Page N" (customize with
getPageLabel); the current one hasaria-current="page". - Previous/next are disabled on the first/last page and named by
prevButtonLabel/nextButtonLabel; visible captions are hidden from assistive tech to avoid double reading. - Ellipses are
aria-hidden.
API
Pagination
Page navigation with previous/next buttons, boundary and sibling pages and ellipses.
| Prop | Type | Default | Description |
|---|---|---|---|
| boundaryCount | number | 1 | Pages always shown at each end. |
| className | string | — | |
| currentPage | number | — | Current page (1-based). Leave undefined to let the component track it. |
| defaultCurrentPage | number | 1 | Initial page when uncontrolled. |
| disabled | boolean | false | |
| getPageLabel | ((page: number, isCurrent: boolean) => string) | (page) => `Page ${page}` | Accessible name of a page button. |
| navigationButtonsStyle | "caption" | "both" | "icon" | icon | |
| navigationLabel | string | Pages | Hidden heading that labels the navigation landmark. |
| nextButtonCaption | string | Next | |
| nextButtonLabel | string | Next page | |
| onChange | ((page: number, event: MouseEvent<HTMLElement, MouseEvent>) => void) | — | |
| prevButtonCaption | string | Previous | |
| prevButtonLabel | string | Previous page | |
| renderNavigationButton | ((props: PaginationNavigationRenderProps) => ReactNode) | — | |
| renderPageButton | ((props: PaginationPageRenderProps) => ReactNode) | — | Render a page button yourself, e.g. as a router link. Spread the props onto it. |
| siblingCount | number | 1 | Pages shown on each side of the current one. |
| totalPages | number | 1 |