Back to Components

Pagination

A self-contained pagination component with four visual variants, each independently functional. Every variant smoothly animates its active-page highlight with Framer Motion. Render all four stacked, or a single variant via the variant prop.

Preview

Installation

Install the component using the CLI.

npx shadcn@latest add https://shreyashtech.me/r/pagination.json

Usage

Import the component:

import Pagination from "@/components/pagination"

Use it in your code:

<Pagination />

Props

PropertyTypeDefaultDescription
totalPagesnumber40Total number of pages.
pagenumber-Controlled current page (1-indexed). Pass with onPageChange.
defaultPagenumber1Uncontrolled initial page. Ignored if page is provided.
onPageChangefunction-Called whenever the page changes, from any variant.
variant"pills" | "outline" | "compact" | "input"all fourRender only this single variant instead of the full four-row demo.
variantsPaginationVariant[]["pills", "outline", "compact", "input"]Which variants to render in showcase mode (ignored if variant is set). Reorder or remove entries to change what's shown.
showInputbooleantrueShow the "Go to page" input on the input variant.
disabledbooleanfalseDisable every control in every rendered variant.
siblingCountnumber2How many pages to show on each side of the current page.
classNamestring-Extra classes applied to the outermost wrapper.