Skip to Content

Pagination

A pagination component lets users navigate through content split across multiple pages.

Expand code
<Pagination pages={10}/>

Pages

The pages prop defines how many pages will be available to navigate.

Expand code
<Pagination pages={3}/> <Pagination pages={15}/>

Active page

You can set the currently selected page with the activePage prop.
If the prop is omitted, it will fall back to 1.

Expand code
<Pagination pages={12} activePage={6}/>

The currently selected page must not be greater than the number of total pages and must be at least 1.

Change detection

You can handle navigation changes with the prop onChange. The function will be called whenever one of the controls or any visible page is clicked.

current page: 1
Expand code
const [page, setPage] = React.useState(1); <div>current page: {page}</div> <Pagination pages={10} activePage={page} onChange={setPage}/>

Controls

Visibility

The props disableFirstButton, disablepreviousButton, disableNextButton and disableLastButton determine whether a control should be hidden.
By default, all controls are visible.

Expand code
<Pagination pages={10} disableFirstButton disableLastButton/> <Pagination pages={10} disableNextButton disablePrevButton/> <Pagination pages={10} disableFirstButton disableLastButton disableNextButton disablePrevButton/>

Custom icons

You can use different icons for the controls, by using the firstButton, previousButton, nextButton or lastButton prop.

Expand code
// const first = <svg>...</svg> // const last = <svg>...</svg> <Pagination pages={10} firstButton={first} lastButton={last} disableNextButton disablePrevButton/>

Boundary

The boundary prop sets the amount of visible entries at the bounds of the pagination.

Expand code
<Pagination pages={15} activePage={7} boundary={3}/>

The boundary must not be greater than the number of total pages and must be at least 1.

Siblings

Customize the amount of visible pages around the currently selected page with the siblings prop.

Expand code
<Pagination pages={15} activePage={7} siblings={3}/>

Accessibility

Every control and page has the ARIA attribute aria-label. You can customize it by using the ariaLabels prop.
By default, the aria-label attributes are set to Go to (first/previous/next/last/) page and Go to page x.

Expand code
const aria: AriaLabels = { first: 'First page', last: 'Last page', next: 'Next page', prev: 'Previous page', page: 'Page' }; <Pagination pages={10} ariaLabels={aria}/>

Props

NameTypeDefaultDescription
activePagenumber1currently selected page
ariaLabelsobject-Sets the aria-label attributes for the controls and pages
boundarynumber1Visible pages at the pagination bounds
disableFirstButtonbooleanfalseEnable or disable the first page control
disableLastButtonbooleanfalseEnable or disable the last page control
disableNextButtonbooleanfalseEnable or disable the next page control
disablePrevButtonbooleanfalseEnable or disable the previous page control
firstButtonnode-Use a custom icon
lastButtonnode-Use a custom icon
nextButtonnode-Use a custom icon
onChangefunction-On change, get the current page
prevButtonnode-Use a custom icon
pagesnumber-Number of available pages
siblingsnumber1Number of pages surrounding the selected page
Last updated on