Pagination
Enable users to navigate efficiently through large datasets or content spanning multiple pages. Allow customization of the number of items displayed per page.
#Examples
Pagination is a crucial navigation element for large datasets or lengthy content. It breaks information into manageable chunks, preventing overwhelm and improving the user experience.
Pagination is composed of
- Total item count: Clearly show the range of currently visible items (e.g., "1-10 of 100").
- Navigation controls:
- Previous/Next buttons: Use clear icons (e.g., chevrons) or text labels.
- First/Last buttons (optional): Include for large datasets to enable quick navigation.
- Page number information and input field (optional): Display the current page and allow direct input for specific pages (e.g., "Page 3 of 10").
- Items per page (optional): Allow users to adjust the number of items displayed per page.
1 - 5 of 1000 items
const [page, setPage] = useState(1);
const [pageSize, setPageSize] = useState(5);
const allData = Array.from(Array(1000).keys());
const pagedData = allData.slice((page - 1) * pageSize, page * pageSize);
return (
<Pagination
count={pagedData.length}
total={allData.length}
page={page}
setPage={setPage}
pageSize={pageSize}
setPageSize={setPageSize}
cancelLabel="Cancel"
confirmLabel="Confirm"
firstLabel="First"
prevLabel="Previous"
nextLabel="Next"
lastLabel="Last"
pagingInfoLabel={(startIdx: number, endIdx: number, total: number) =>
`${startIdx} - ${endIdx} of ${total} items`
}
pageLabel="Page"
pageXofYLabel={(current: number, total: number) => `Page ${current} of ${total}`}
pageSizeSelectionLabel={(pageSize: number) => `${pageSize} items`}
pageSizeSelectorPrefix="Show"
pageSizeSelectorPostfix="per page"
pageSizeLabel="Items per page"
defaultError="Default pagination error"
wholeNumberError="Must be a whole number"
outOfBoundsError={(total: number) => `Enter a number between 1 and ${total}`}
ariaLabel="Pagination"
/>
);
#Properties
1 - 5 of 25 items
Property | Description | Defined | Value |
---|---|---|---|
totalRequired | number Total count of items | ||
pageRequired | number Selected page number | ||
setPageRequired | function Callback to change the selected page | ||
pageSizeRequired | number Selected page size | ||
setPageSizeRequired | | function Callback to change the selected page size | ||
cancelLabelRequired | string Label for the cancel button | ||
confirmLabelRequired | string Label for the confirm button | ||
firstLabelRequired | string Tooltip text for the first button | ||
prevLabelRequired | string Tooltip text for the previous button | ||
nextLabelRequired | string Tooltip text for the next button | ||
lastLabelRequired | string Tooltip text for the last button | ||
pagingInfoLabelRequired | function Label for paging info - something like `${startIdx} - ${endIdx} of ${total} items` | ||
pageLabelRequired | string Label for page input | ||
pageXofYLabelRequired | function Label for page dropdown button - something like `Page ${current} of ${total} | ||
pageSizeSelectionLabelRequired | function Label for pageSize dropdown button - something like `${pageSize} items` | ||
pageSizeSelectorPrefixRequired | string Label before pageSize changer - Show (<- this part) DROPDOWN per page | ||
pageSizeSelectorPostfixRequired | string Label after pageSize changer - Show DROPDOWN per page (<- this part) | ||
pageSizeLabelRequired | string Label for pageSize radios - something like "Items per page" | ||
defaultErrorRequired | string Default error for page number input | ||
wholeNumberErrorRequired | string Error for page number input when number is not integer | ||
outOfBoundsErrorRequired | function Error for page number input when number is out of bounds (below 1 and above total) | ||
countOptional | number Count of items | ||
loadingOptional | boolean Loading state | ||
observeKeyPrefixOptional | string Used as data observe key for pagination buttons | ||
ariaLabelOptional | string Text for the ARIA label |
#Guidelines
#Best practices
#Do not use when
#Accessibility
Explore detailed guidelines for this component: Accessibility Specifications