Skip to content

Pagination

Previous, next and numbered pages for a long list, with gaps past the neighbours of the current page.

1.6 kB gzipSource Registry JSON

Pagination playground

Props

Installation

npx shadcn@latest add https://sproutboat.com/ikada/r/pagination.json

The CLI writes components/ikada/pagination.tsx and merges the ikada theme into your CSS. Or take it from the package: import { Pagination } from "@sproutboat/ikada";

Usage

import { Pagination } from "@/components/ikada/pagination";

<Pagination page={page} onPageChange={setPage} pageCount={12} />

Examples

Numbered

The first and last page always show; pages past the current one's neighbours collapse into a gap.

Compact

Previous, next and "Page 1 of 12". Use it on narrow screens.

Siblings

Show more pages either side of the current one.

Props

PaginationProps
PropTypeDescription
pagerequirednumberCurrent page, starting at 1.
pageCountrequirednumberTotal number of pages.
onPageChangerequired(page: number) => voidCalled with the page to go to.
compactbooleanPrevious and next plus "Page 3 of 12", no number buttons. Use it on narrow screens. Default `false`.
siblingsnumberPages shown either side of the current one. Default 1.

Also takes every prop of Omit<ComponentProps<"nav">, "onChange">.

Source: src/components/pagination.tsx