Pagination

Page numbers with ellipses, a range summary, and a compact form for small screens.

Category
Navigation & layout
Access
Free with an account
Source
131 lines · one file

When to use it

Use Pagination for page numbers under a list or table: previous and next, siblings around the current page, and an optional "1–10 of 240" summary.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Liro's Pagination for this.
Install it: npx shadcn@latest add @liro/pagination
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/pagination.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Free components install through the @liro registry with your CLI token: see the Namespaced tab.

Usage

components/pager.tsx
import * as React from "react";
import { Pagination } from "@/components/ui/pagination";

export function Pager({ total }: { total: number }) {
  const [page, setPage] = React.useState(1);
  return <Pagination page={page} pageCount={Math.ceil(total / 10)} onPageChange={setPage} total={total} pageSize={10} />;
}

API reference

“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

TypeNotes
pagenumber Yes1-based.
pageCountnumber Yes–
onPageChange(page: number) => void Yes–
totalnumber NoTotal rows — with `pageSize`, shows "41–60 of 473".
pageSizenumber No–
siblingsnumber NoPages either side of the current one. Default 1.
compactboolean NoHide the numbers and show "Page 3 of 24" — for narrow spaces.
labelstring NoWhat is being paged, for the nav's name: "Invoices".

Dependencies

npm packages

clsxframer-motionlucide-reacttailwind-merge

Liro foundations, installed alongside it

liro-theme

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances