Skip to Content
NarakUI

Pagination

A navigation component for splitting content across multiple pages.

Default

Shows the visible item range and the previous and next arrows. It fills its container, so it usually sits in a table footer.

Showing 21 – 30 of 248 items

With page indicator

Shows the current page and the page count between the arrows.

Showing 1 – 10 of 50 items

Arrows only

Hides the item count and keeps only the arrows.

Cursor mode

Use mode="cursor" when the API returns a next-page cursor instead of a total. Pass hasNextPage instead of limit, offset, and totalItems. The count reads Page N, and showPageIndicatorBetweenArrows has no effect.

Page 1

Loading state

isLoading disables both arrows while data is fetching.

Showing 11 – 20 of 248 items

Empty state

With zero items, the count is hidden and both arrows are disabled.

Installation

pnpm dlx shadcn@latest add @narakui/pagination

Add "@narakui": "https://ui.narakcode.dev/r/{name}.json" to components.json, or install directly from https://ui.narakcode.dev/r/pagination.json.

Usage

import { Pagination } from '@/components/ui/pagination';
<Pagination
  page={1}
  limit={10}
  offset={0}
  totalItems={100}
  onPageChange={setPage}
/>

Properties

PropTypeDefaultDescription
page (Required)number—The current page number (1-based).
onPageChange (Required)(page: number) => void—Called with the new page when an arrow is clicked.
mode'counted' | 'cursor''counted'counted takes a total and shows the item range; cursor only knows whether a next page exists.
limitnumber—Number of items per page. Required in counted mode.
offsetnumber—Number of items to skip, usually (page - 1) * limit. Required in counted mode.
totalItemsnumber—Total number of items across all pages. Required in counted mode.
hasNextPageboolean—Whether a next page exists. Required in cursor mode.
isLoadingbooleanfalseDisables both arrows.
showOnlyArrowsbooleanfalseShow only navigation arrows without item count.
showPageIndicatorBetweenArrowsbooleanfalseShow the current page and page count between the arrows. Counted mode only.
leftContentReactNode—Content shown before the item count.
alignTextstring—Set to 'end' to align the item count to the right.
aria-labelstring'Pagination'Accessible name for the navigation landmark. Change it when a view has more than one.
classNamestring—Additional CSS classes to apply to the pagination container.