@zendeskgarden/react-pagination package provides two pagination variants: OffsetPagination for numbered page navigation, and CursorPagination for first/previous/next/last navigation. Both are fully accessible and keyboard-navigable.
Installation
Place a
ThemeProvider from @zendeskgarden/react-theming at the root of your React application. All Garden components must be rendered inside a ThemeProvider.OffsetPagination
OffsetPagination renders a numbered page list with previous and next controls. It automatically shows gap indicators (…) when the total number of pages exceeds the visible window.
Basic usage
Customizing the page window
UsepagePadding to control how many pages appear on either side of the current page, and pageGap to control where gap indicators appear relative to the first and last pages.
Localized labels
Provide thelabels prop to override the accessible labels for previous, next, and gap elements, and to customize the per-page button label.
Props
The currently active page number. Pages are 1-indexed.
The total number of pages.
Callback fired when the user navigates to a different page. Receives the new page number.
The number of pages to display on either side of the current page before showing a gap indicator.
Controls the position of the leading and trailing gap indicators relative to the first and last pages.
Localized accessible labels for pagination controls.
CursorPagination
CursorPagination provides first, previous, next, and last navigation controls without numbered pages. It is suitable for APIs that return cursor tokens rather than page numbers.
Basic usage
Subcomponents
CursorPagination exposes four navigation button subcomponents. Each accepts all ButtonHTMLAttributes<HTMLButtonElement> props.
| Subcomponent | Description |
|---|---|
CursorPagination.First | Navigates to the first page |
CursorPagination.Previous | Navigates to the previous page |
CursorPagination.Next | Navigates to the next page |
CursorPagination.Last | Navigates to the last page |
Exports
The following are exported from@zendeskgarden/react-pagination:
| Export | Description |
|---|---|
OffsetPagination | Numbered page pagination component |
CursorPagination | First/previous/next/last cursor-based pagination |