Skip to main content

Pagination Component

The <Pagination> component renders previous/next buttons and the page numbers between them. It is the same pagination used in the footer of the <Table> component.

Basic Usage​

The number of pages is calculated from itemsLength and itemsPerPage, or can be passed directly with pageCount.

import { Pagination } from "react-better-html";

function App() {
return (
<Pagination
itemsLength={240}
itemsPerPage={20}
onChangePage={(page) => console.log("Current page:", page)}
/>
);
}

Common Props​

  • currentPage - the selected page (defaults to 1). Changing it from outside updates the component
  • itemsLength / itemsPerPage - used to calculate the number of pages
  • pageCount - the number of pages (takes precedence over itemsLength and itemsPerPage)
  • maximumVisiblePages - how many page numbers are visible at once (defaults to 11)
  • onChangePage - called with the new page every time it changes
  • onClickPreviousPage / onClickNextPage - called with the new page when the arrow buttons are clicked