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

CLI

$ 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

Manual

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

  2. Copy the source into components/ui/pagination.tsx:

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.

Usage

import { Pagination, PaginationContent, PaginationItem, PaginationLink, PaginationPrevious, PaginationNext, PaginationFirst, PaginationLast, PaginationEllipsis, PaginationSummary, PaginationGroup, PaginationInput } from "@/components/ui/pagination"
<NumberedExample />

Links render as a elements, so pass href for real routes, or href="#" with an onClick that calls preventDefault() for client-side state. Mark the current page with isActive on PaginationLink. To disable an edge link, set aria-disabled on it; it becomes non-interactive and dimmed.

PaginationLink takes a size from the Button sizes and defaults to icon-sm. Set text="" on PaginationPrevious or PaginationNext for icon-only arrows.

Examples

Compact

A page number input with joined previous and next arrows in a PaginationGroup, clamping 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 range summary, and first, previous, next and last 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

A long page range shortened with ellipses on both sides of the current page.

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

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

Custom labels

Previous and next links relabelled 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

Page links using the larger icon button size.

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

export default function PaginationLargeLinks() {
  return (
    <Pagination>
      <PaginationContent>
        {[1, 2, 3, 4, 5].map((page) => (
          <PaginationItem key={page}>
            <PaginationLink href="#" size="icon" isActive={page === 1}>
              {page}
            </PaginationLink>

API Reference

Anatomy7 parts
<Pagination>
<PaginationContent>
<PaginationItem>
<PaginationPrevious />
<PaginationLink />
<PaginationEllipsis />
<PaginationNext />
</PaginationItem>
</PaginationContent>
</Pagination>
01

Pagination

The nav landmark that contains the pagination controls.

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

02

PaginationContent

The list that holds the pagination items.

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

03

PaginationItem

A list item wrapper for one link or ellipsis.

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

04

PaginationLink

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

PropTypeDefaultDescription
isActiveboolean-Marks the link as the current page with aria-current="page".

Also accepts the props of PaginationLinkProps.

05

PaginationPrevious

A link to the previous page with a leading caret.

PropTypeDefaultDescription
textstring"Previous"The visible label. A custom value also becomes the accessible name; an empty string renders an icon-only link.
isActiveboolean-Marks the link as the current page with aria-current="page".

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

06

PaginationNext

A link to the next page with a trailing caret.

PropTypeDefaultDescription
textstring"Next"The visible label. A custom value also becomes the accessible name; an empty string renders an icon-only link.
isActiveboolean-Marks the link as the current page with aria-current="page".

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

07

PaginationFirst

An icon link to the first page.

PropTypeDefaultDescription
isActiveboolean-Marks the link as the current page with aria-current="page".

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

08

PaginationLast

An icon link to the last page.

PropTypeDefaultDescription
isActiveboolean-Marks the link as the current page with aria-current="page".

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

09

PaginationEllipsis

A placeholder that indicates skipped pages.

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

10

PaginationSummary

Secondary text that summarizes the current range.

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

11

PaginationGroup

Joins several links into one segmented control.

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

12

PaginationInput

A numeric text field for jumping to a page.

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

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.
  • PaginationEllipsis is hidden from assistive technology.
  • PaginationGroup has role="group".
  • PaginationInput has no built-in label; associate one with htmlFor or aria-label.

Notes

  • Styling hooks: data-slot values pagination, pagination-content, pagination-item, pagination-link, pagination-ellipsis, pagination-summary, pagination-group and pagination-input. Active links expose data-active.
  • Active links use the secondary button variant and others use ghost.
  • Previous and next text is hidden below the sm breakpoint, and the carets flip in right-to-left layouts.
  • PaginationInput uses inputMode="numeric" to show a number keypad on touch devices.
NextPin PadPreviousPage Indicator

On this page

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