Pagination

A Pagination component walks through a result set page by page, showing the current page, its neighbours and the ends of the range with an ellipsis in between. It keeps a long list navigable without loading all of it at once.

Demo

Rendered live, with the same build of the library you install.

Nine pages:

With a summary:

Usage

Pagination.tsx
import { useState } from 'react';
import { NPagination } from '@nayan-ui/react';
const Pagination = () => {
const [page, setPage] = useState(3);
return (
<div>
<h3 className="text-foreground mb-2 mt-4 text-sm font-semibold">Nine pages:</h3>
<div className="mb-5">
<NPagination totalPages={9} currentPage={page} onChange={setPage} />
</div>
<h3 className="text-foreground mb-2 mt-4 text-sm font-semibold">With a summary:</h3>
<NPagination totalPages={40} currentPage={page} onChange={setPage} showSummary />
</div>
);
};
export default Pagination;

Attributes

13 props
NameTypeDefaultDetails
totalPagesnumberRequiredThe totalPages prop.
currentPagenumberRequiredThe currentPage prop.
onChange(page: number) => voidRequiredThe onChange prop.
size'sm' | 'md' | 'lg''md'The size prop.
disabledbooleanfalseThe disabled prop.
showSummarybooleanfalseThe showSummary prop.
summaryTextstringOptionalThe summaryText prop.
siblingCountnumber1The siblingCount prop.
classNamestring''The className prop.
contentClassNamestring''The contentClassName prop.
linkClassNamestring''The linkClassName prop.
activeLinkClassNamestring''The activeLinkClassName prop.
aria-labelstring'Pagination'The aria-label prop.

Tags

Other components solving nearby problems.