Skip to content
caliper ui docs

Components

Pagination

Page links with previous and next, sized for touch.

Free
pnpm dlx shadcn@latest add @caliper/pagination

Invoices

236 this year · showing 41–60

  • INV-0196$1,232.00
  • INV-0195$1,195.00
  • INV-0194$2,058.00
Installs components/ui/pagination.tsxDepends on @radix-ui/react-slot, lucide-reactMotion none in component source

When to use

Use it for

  • Long result sets where position matters.
  • Tables and directories.

Skip it when

  • Feeds; load more instead.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/pagination

Adds its 3 files to components/ui/, each with its own stylesheet, and installs their packages. No account needed. The first part also adds Caliper UI’s tokens; import them once as in Installation.

Usage

This is the code behind the preview above.

example.tsx
import { useState, type ReactNode } from "react"
import { Pagination } from "@/components/ui/pagination"
import { cn } from "@/components/ui/lib/cn"

function Panel({ title, context, media, action, className, children }: { title: string; context: string; media?: ReactNode; action?: ReactNode; className?: string; children?: ReactNode }) {
  return (
    <section className={cn("grid w-full max-w-md gap-5 rounded-overlay border border-border bg-background p-6 shadow-resting", className)}>
      <div className="flex items-center gap-3">
        {media}
        <div className="grid min-w-0 flex-1 gap-1">
          <p className="font-medium">{title}</p>
          <p className="text-sm text-muted-foreground">{context}</p>
        </div>
        {action}
      </div>
      {children}
    </section>
  );
}

export function ResultPages() {
  const [page, setPage] = useState(3);
  const first = 236 - (page - 1) * 20;
  return (
    <Panel title="Invoices" context={`236 this year · showing ${(page - 1) * 20 + 1}–${Math.min(page * 20, 236)}`}>
      <ul className="grid gap-2 text-sm">
        {[0, 1, 2].map((offset) => (
          <li key={offset} className="flex items-center justify-between gap-3">
            <span className="font-medium tabular-nums">INV-{String(first - offset).padStart(4, "0")}</span>
            <span className="tabular-nums text-muted-foreground">${(1180 + ((first - offset) * 37) % 900).toLocaleString("en-US")}.00</span>
          </li>
        ))}
      </ul>
      <Pagination page={page} pageCount={12} onPageChange={setPage} />
    </Panel>
  );
}

API reference

Pagination

component

Also accepts the native props of its root element and a ref.

PropTypeDefault
page *number—
pageCount *number—
onPageChange *(page: number) => void—
labelstring"Pagination"

Accessibility

It exposes status semantics, with aria-label, aria-disabled, aria-hidden, aria-atomic and aria-current kept in step with state. Changes that matter are announced through a live region.

No custom key handling; Tab and the native activation keys do the work.

Motion

It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.

All Identity & navigation examples