Paginator

The paginator component allows dividing large amounts of content into multiple pages.

Props

NameTypeDescriptionDefault
currentPagenumberNumber of the current selected page.1
itemsPerPagenumberNumber of items per page.5
itemsPerPageOptionsnumber[]An array of numbers representing the items per page options. If undefined, the select with items per page options will not be displayed.-
itemsPerPageFunction(itemsPerPage: number) => voidThis function will be called when the user selects an item per page option. The number of items per page will be passed as a parameter to this function.-
totalItemsnumberTotal number of items in the pages.1
showGoToPagebooleanIf true, a select will be displayed with the page numbers to move through themfalse
onPageChange(page: number) => voidThis function will be called when the user clicks on any of the button to change pages. The page number will be passed as a parameter to this function.-
tabIndexnumberValue of the tabindex attribute.0

Examples

Items per page

This is an example of how to display 'Items per Page' select and how to handle it through the itemsPerPageFunction function.

() => {
  const [page, changePage] = useState(1);
  const [items, changeItems] = useState(10);
  const itemsPerPageClick = (value) => {
    changeItems(value);
  };

  return (
    <DxcInset space="2rem">
      <DxcPaginator
        currentPage={page}
        itemsPerPage={items}
        itemsPerPageOptions={[5, 10, 15]}
        itemsPerPageFunction={itemsPerPageClick}
        totalItems={27}
      />
    </DxcInset>
  );
}