For the complete documentation index, see llms.txt. This page is also available as Markdown.

Pagination Helpers

Various helpers related to pagination specific functionality.

Source code is hosted on GitHub

yarn add @corets/pagination-helpers
npm install --save @corets/pagination-helpers

createPagination()

Calculates total amount of pages, visible pages, more / less indicators, total items, etc., this helper can be used to build a pagination like this:

< << ... 6 7 8 [9] 10 11 12 ... >> >
< << 7 8 [9] 10 11 >> >
<  ... 7 8 [9] 10 11  ... >
< [9] >
[ v Select page ]

Calculate pagination:

import { createPagination } from "@corets/pagination-helpers"

// active page
const currentPage = 7

// total number of items for pagination
const totalItems = 1337

// how many items are visible on a single page
const pageSize = 20

// how many pages you want to display to the left and right of the current page
const surroundBy = 2
const pagination = createPagination({ currentPage, totalItems, pageSize, surroundBy })

With the calculated result below you can build every possible kind of pagination you can think of:

Last updated

Was this helpful?