Pagination
Page navigation for paged content: page buttons with ellipses, optional Previous/Next and First/Last buttons, inside a <nav> landmark named "Pagination" (override with aria-label).
onPageChange is an event callback: it fires on every activation, including the current page. Boundary buttons that point at the current page use aria-disabled and keep focus; the whole control is disabled with disabled. Button names are localized with getItemAriaLabel.
Examples
Default
export const Default: Story = {};Many Pages
export const ManyPages: Story = {
args: {
totalPages: 50,
defaultCurrentPage: 25,
},
};Small Size
export const SmallSize: Story = {
args: {
size: 'small',
},
};With First Last
export const WithFirstLast: Story = {
args: {
totalPages: 20,
showFirstLast: true,
defaultCurrentPage: 10,
},
};Disabled
export const Disabled: Story = {
args: {
disabled: true,
defaultCurrentPage: 3,
},
};Localized
export const Localized: Story = {
args: {
'aria-label': 'Sidenavigasjon',
lang: 'nb',
showFirstLast: true,
getItemAriaLabel: norwegianLabels,
},
};Controlled
Current page: 3
export const Controlled: Story = {
render: ({ onPageChange, ...args }) => {
const [page, setPage] = React.useState(3);
return (
<div className="flex flex-col gap-4">
<Pagination
currentPage={page}
onPageChange={(next) => {
setPage(next);
onPageChange?.(next);
}}
{...args}
/>
<p className="text-wave-body-1">Current page: {page}</p>
</div>
);
},
};Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
currentPage | number | No | Controlled current page number (1-based). A value outside | |
defaultCurrentPage | number | No | 1 | Default current page for uncontrolled usage. When the current page falls outside |
totalPages | number | Yes | Total number of pages. A fractional value is rounded down; | |
onPageChange | (page: number) => void | No | Called with the target page whenever a page, First, Previous, Next or Last button is activated — also when the current page is activated again (0.4 semantics) — and once when the current page is clamped into | |
siblingCount | number | No | 1 | Number of page buttons to show on each side of the current page. |
boundaryCount | number | No | 1 | Number of page buttons to always show at the start and end. With |
showPreviousNext | boolean | No | true | Whether to show previous/next navigation buttons. |
showFirstLast | boolean | No | false | Whether to show first/last page navigation buttons. |
disabled | boolean | No | false | Whether the entire pagination control is disabled (every button gets the native |
size | 'small' | 'medium' | No | 'medium' | Size of the pagination buttons. |
getItemAriaLabel | (type: PaginationItemType, page: number, selected: boolean) => string | No | Accessible name of each button, for localization. | |
ref | React.Ref<HTMLElement> | No | Ref to the root | |
slotProps | { list?: SlotPart<'ol'>; listItem?: SlotPart<'li'>; firstButton?: SlotPart<'button'>; previousButton?: SlotPart<'button'>; pageButton?: SlotPart<'button'>; nextButton?: SlotPart<'button'>; lastButton?: SlotPart<'button'>; ellipsis?: SlotPart<'span'> } | No | Props for the elements the control draws inside its landmark, by part, merged into each part's own: your classes after the part's (yours win a conflict), your styles over its styles, your attributes and handlers added, your ref attached. Every attribute the control sets on a part is locked, and no part takes another role or hides what it holds. A part takes no |
Any other prop is passed to the element it renders (HTMLElement).
Parts
listlistItemfirstButtonpreviousButtonpageButtonnextButtonlastButtonellipsis
Stable class names
| Part | Class |
|---|---|
root | wave-pagination |
list | wave-pagination__list |
listItem | wave-pagination__list-item |
firstButton | wave-pagination__first-button |
previousButton | wave-pagination__previous-button |
pageButton | wave-pagination__page-button |
nextButton | wave-pagination__next-button |
lastButton | wave-pagination__last-button |
ellipsis | wave-pagination__ellipsis |