Skip to Content
zjkm-ui
Components

Pagination

Numbered pages with ellipses for long ranges.

Props
20
1
<Pagination page={page} onChange={setPage} total={20} />

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/pagination.json
import { Pagination } from "@/components/pagination"

Using JavaScript? Set tsx: false in components.json and the CLI converts it.

New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.

Usage

Numbered pages with Previous and Next. Long ranges collapse into ellipses, keeping the first and last pages and the ones around the current page. pageList is exported if you want the same numbers elsewhere.

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

export function Results({ total }: { total: number }) {
  const [page, setPage] = useState(1);
  return <Pagination page={page} total={total} onChange={setPage} />;
}

Props

PropTypeDefaultDescription
pagenumberThe current page, from 1.
totalnumberNumber of pages.
onChange(page: number) => voidCalled with the chosen page.
siblingsnumber1Pages shown either side of the current one.
labelstring"Pagination"Accessible name.
classNamestringClasses for the nav.

It has no animation, so reduced motion changes nothing.

On this page