Skip to main content

Pagination

v.6.0.0

Installation

yarn add @mercell/pagination-react

Usage

Using the Pagination component is as simple as importing it like this.

import { Pagination } from '@mercell/pagination-react';
Live Editor
Result

Types, definitions, etc.

PaginationProps
interface PaginationProps {
totalCount: number;
currentPage: number;
pageSize: number;
onPageChange: (currentPage: number) => void;
siblingCount?: number;
ariaLabels?: {
prevPageButton?: string;
nextPageButton?: string;
pageButton?: string;
};
} & JSX.IntrinsicElements['nav']
NameTypeDefaultRequiredDescription
totalCountnumber-yesArray length of data
currentPagenumber-yesCurrent page
pageSizenumber-yesItem per page
onPageChangefunction-yesAction on page change
siblingCountnumber1noCalculating how many elements should be in between e.g. 1 ... 4 5 6 ... or 1 ... 5 ...
ariaLabelsobject-noObject containing aria labels for prev, next and page button
prevPageButtonstring-noPrev button aria label, part of ariaLabel object
nextPageButtonstring-noNext button aria label, part of ariaLabel object
pageButtonstring-noPage button aria label, part of ariaLabel object