suiss/ui
  • Docs
  • Components
  • Patterns
  • Interactions
  • Charts
  • Blocks
  • AI
GitHubCreate
DocsComponentsPatternsInteractionsChartsBlocksAICreate
Components84
  • Overview
  • Accordion
  • Alert
  • Alert Dialog
  • Alert Sheet
  • Amount Input
  • Aspect Ratio
  • Attachment
  • Avatar
  • Badge
  • Bottom Bar
  • Breadcrumb
  • Bubble
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Chip
  • Code Block
  • Collapsible
  • Combobox
  • Command
  • Context Menu
  • Dialog
  • Direction
  • Drawer
  • Dropdown Menu
  • Empty
  • FAB
  • Field
  • Fullscreen Menu
  • Haptics
  • Header
  • Hover Card
  • Icon
  • Input
  • Input Accessory Bar
  • Input Group
  • Input OTP
  • Item
  • Kbd
  • Keyboard Scroll View
  • Keypad
  • Label
  • Marker
  • Menubar
  • Message
  • Message Scroller
  • Native Select
  • Navigation Menu
  • Page Indicator
  • Pagination
  • Pin Pad
  • Popover
  • Progress
  • QR Scanner
  • Questionnaire
  • Radio Group
  • Resizable
  • Screen
  • Scroll Area
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Signature Pad
  • Skeleton
  • Slider
  • Spinner
  • Switch
  • Tab Bar
  • Table
  • Tabs
  • Text
  • Textarea
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Trace
  • Wheel Picker
  • Widget

suiss/ui · Component

Pagination

Navigation links for moving between pages of content, such as table results.

Pagination is an open-source component from suiss/ui for React. The @esuiss/ui CLI copies its source into your project, so you own the code.

import * as React from "react"
import {
  Pagination,
  PaginationContent,
  PaginationEllipsis,
  PaginationItem,
  PaginationLink,
  PaginationNext,
  PaginationPrevious,
  PaginationSummary,
} from "@/components/ui/pagination"
import {
  Table,
  TableBody,
  TableCell,
  TableHead,

Pagination is a set of link primitives you compose around your own page state. Pagination is the nav landmark. Inside it, PaginationContent is a list of PaginationItem entries, each holding a PaginationLink, PaginationPrevious, PaginationNext, PaginationFirst, PaginationLast or PaginationEllipsis.

For compact toolbars, PaginationGroup joins arrow links into one segmented control, PaginationInput lets the user type a page number, and PaginationSummary shows a range such as 6–10 / 62. The component does not calculate page ranges; you decide which links to render.

Installation

$ pnpm dlx shadcn@latest add @esuiss/pagination

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add pagination
  1. Install the following dependencies and add the cn helper:
$ pnpm add @phosphor-icons/react class-variance-authority
  1. Add the pieces it builds on: Button.

  2. Copy and paste the following code into your project.

components/ui/pagination.tsx
"use client"

import {
  CaretDoubleLeftIcon,
  CaretDoubleRightIcon,
  CaretLeftIcon,
  CaretRightIcon,
  DotsThreeIcon,
} from "@phosphor-icons/react"
import type { VariantProps } from "class-variance-authority"
import type * as React from "react"
import { buttonVariants } from "@/components/ui/button"
import { cn } from "@/lib/utils"

function Pagination({ className, ...props }: React.ComponentProps<"nav">) {
  return (
  1. Update the import paths to match your project setup.

Usage

import {
  Pagination,
  PaginationContent,
  PaginationEllipsis,
  PaginationFirst,
  PaginationGroup,
  PaginationInput,
  PaginationItem,
  PaginationLast,
  PaginationLink,
  PaginationNext,
  PaginationPrevious,
  PaginationSummary,
} from "@/components/ui/pagination"
<Pagination>
  <PaginationContent>
    <PaginationItem>
      <PaginationPrevious href="/orders?page=1" />
    </PaginationItem>
    <PaginationItem>
      <PaginationLink href="/orders?page=1">1</PaginationLink>
    </PaginationItem>
    <PaginationItem>
      <PaginationLink href="/orders?page=2" isActive>
        2
      </PaginationLink>
    </PaginationItem>
    <PaginationItem>
      <PaginationLink href="/orders?page=3">3</PaginationLink>
    </PaginationItem>
    <PaginationItem>
      <PaginationEllipsis />
    </PaginationItem>
    <PaginationItem>
      <PaginationNext href="/orders?page=3" />
    </PaginationItem>
  </PaginationContent>
</Pagination>

Composition

Use the following composition to build a Pagination:

Pagination
├── PaginationContent
│   └── PaginationItem
│       ├── PaginationPrevious
│       ├── PaginationLink
│       ├── PaginationEllipsis
│       └── PaginationNext
├── PaginationSummary
├── PaginationInput
└── PaginationGroup
    ├── PaginationFirst
    ├── PaginationPrevious
    ├── PaginationNext
    └── PaginationLast

Examples

Compact

A PaginationInput for the page number with previous and next arrows joined in a PaginationGroup. Set text="" on PaginationPrevious or PaginationNext for icon-only arrows. The example clamps typed values to the valid range.

import * as React from "react"
import {
  Pagination,
  PaginationGroup,
  PaginationInput,
  PaginationNext,
  PaginationPrevious,
} from "@/components/ui/pagination"
import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@/components/ui/table"

Rows per page

A rows-per-page select, a PaginationSummary with the current range, and PaginationFirst, PaginationPrevious, PaginationNext and PaginationLast arrows.

import * as React from "react"
import {
  Pagination,
  PaginationFirst,
  PaginationGroup,
  PaginationLast,
  PaginationNext,
  PaginationPrevious,
  PaginationSummary,
} from "@/components/ui/pagination"
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,

With ellipsis

Use PaginationEllipsis on both sides of the current page to shorten a long page range.

import {
  Pagination,
  PaginationContent,
  PaginationEllipsis,
  PaginationItem,
  PaginationLink,
  PaginationNext,
  PaginationPrevious,
} from "@/components/ui/pagination"

export default function PaginationWithEllipsis() {
  return (
    <Pagination>
      <PaginationContent>
        <PaginationItem>
          <PaginationPrevious href="#" />

Custom labels

Use the text prop to relabel the previous and next links Newer and Older.

import {
  Pagination,
  PaginationContent,
  PaginationItem,
  PaginationNext,
  PaginationPrevious,
} from "@/components/ui/pagination"

export default function PaginationCustomLabels() {
  return (
    <Pagination>
      <PaginationContent>
        <PaginationItem>
          <PaginationPrevious href="#" text="Newer" />
        </PaginationItem>
        <PaginationItem>

Large links

Set size="icon" on PaginationLink for larger page links.

import {
  Pagination,
  PaginationContent,
  PaginationItem,
  PaginationLink,
} from "@/components/ui/pagination"

export default function PaginationLargeLinks() {
  return (
    <Pagination>
      <PaginationContent>
        <PaginationItem>
          <PaginationLink href="#" size="icon" isActive>
            1
          </PaginationLink>
        </PaginationItem>

Accessibility

  • Pagination renders a nav with aria-label="pagination".
  • The active PaginationLink gets aria-current="page".
  • Arrow links have built-in accessible names: Go to previous page, Go to next page, Go to first page and Go to last page. Custom text on previous or next replaces the name.
  • The PaginationEllipsis icon is hidden from assistive technology, and its visually hidden text, More pages, is read instead.
  • PaginationGroup has role="group".
  • PaginationInput has no built-in label; associate one with htmlFor or aria-label.

API Reference

Pagination

The nav landmark that contains the pagination controls.

Also accepts the props of React.ComponentProps<"nav">.

PaginationContent

The list that holds the pagination items.

Also accepts the props of React.ComponentProps<"ul">.

PaginationItem

A list item wrapper for one link or ellipsis.

Also accepts the props of React.ComponentProps<"li">.

PaginationLink

A page link styled as a button, highlighted when active.

PropTypeDefault
isActiveboolean-
size"default" | "xs" | "sm" | "lg" | "xl" | "form" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | "icon-xl""icon-sm"

Also accepts the props of React.ComponentProps<"a">.

Links render as a elements, so pass href for real routes, or href="#" with an onClick that calls preventDefault() for client-side state. isActive marks the current page with aria-current="page" and the secondary button variant; other links use ghost. size takes a Button size. To disable a link, set aria-disabled on it; it becomes non-interactive and dimmed.

PaginationPrevious

A link to the previous page with a leading caret.

PropTypeDefault
textstring"Previous"
isActiveboolean-
size"default" | "xs" | "sm" | "lg" | "xl" | "form" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | "icon-xl""sm"

Also accepts the props of React.ComponentProps<typeof PaginationLink>.

A custom text also becomes the accessible name. An empty string renders an icon-only link, and size then defaults to "icon-sm". The text is hidden below the sm breakpoint, and the caret flips in right-to-left layouts.

PaginationNext

A link to the next page with a trailing caret.

PropTypeDefault
textstring"Next"
isActiveboolean-
size"default" | "xs" | "sm" | "lg" | "xl" | "form" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | "icon-xl""sm"

Also accepts the props of React.ComponentProps<typeof PaginationLink>.

Works like PaginationPrevious, with a trailing caret.

PaginationFirst

An icon link to the first page.

PropTypeDefault
isActiveboolean-

Also accepts the props of React.ComponentProps<typeof PaginationLink>.

PaginationLast

An icon link to the last page.

PropTypeDefault
isActiveboolean-

Also accepts the props of React.ComponentProps<typeof PaginationLink>.

PaginationEllipsis

A placeholder that indicates skipped pages.

Also accepts the props of React.ComponentProps<"span">.

PaginationSummary

Secondary text that summarizes the current range.

Also accepts the props of React.ComponentProps<"p">.

PaginationGroup

Joins several links into one segmented control.

Also accepts the props of React.ComponentProps<"div">.

PaginationInput

A numeric text field for jumping to a page.

Also accepts the props of React.ComponentProps<"input">.

PaginationInput uses inputMode="numeric" to show a number keypad on touch devices.

Each part sets a data-slot, such as pagination-link or pagination-input, for styling. Active links set data-active.

NextPin PadPreviousPage Indicator

On this page

  1. 01Installation
  2. 02Usage
  3. 03Composition
  4. 04Examples
    • Compact
    • Rows per page
    • With ellipsis
    • Custom labels
    • Large links
  5. 05Accessibility
  6. 06API Reference
    • Pagination
    • PaginationContent
    • PaginationItem
    • PaginationLink
    • PaginationPrevious
    • PaginationNext
    • PaginationFirst
    • PaginationLast
    • PaginationEllipsis
    • PaginationSummary
    • PaginationGroup
    • PaginationInput