StacklyUI
Components/Pagination

PaginationNew

A batteries-included, stateful pagination control — give it a total and it computes the page count, the ellipsis-truncated range, the summary line, and the disabled edge states. The active page is an accent pill that glides between numbers.

01

Preview & playground

Edit the code — the preview updates live. Try changing props, text, or classes.

playground.tsx
function Demo() {
  const [page, setPage] = useState(3)
  return (
    <div className="w-full max-w-md">
      <Pagination
        page={page}
        onPageChange={setPage}
        total={240}
        pageSize={10}
        size="sm"
        showSummary
        showProgress
      />
    </div>
  )
}
render(<Demo />)
02

Examples

Common variations — edit any of them live.

Data-table controls

Summary, a rows-per-page picker, and a go-to-page jumper — everything a table footer needs.

playground.tsx
function Demo() {
  const [page, setPage] = useState(1)
  const [pageSize, setPageSize] = useState(20)
  return (
    <Pagination
      page={page}
      onPageChange={setPage}
      total={1000}
      pageSize={pageSize}
      onPageSizeChange={setPageSize}
      pageSizeOptions={[10, 20, 50, 100]}
      showSummary
      showJumper
    />
  )
}
render(<Demo />)

Compact, more siblings

Small size, no edge jumps, two siblings each side of the current page.

playground.tsx
function Demo() {
  const [page, setPage] = useState(5)
  return (
    <Pagination
      page={page}
      onPageChange={setPage}
      pageCount={10}
      size="sm"
      showEdges={false}
      siblingCount={2}
    />
  )
}
render(<Demo />)
03

Installation

Copy the source into your project with the registry CLI:

$pnpm dlx shadcn@latest add @stacklyui/pagination

Or install the package and import it:

$pnpm add @stacklyui/ui motion
04

Usage

Unlike a bag of static links, this is stateful: pass total (and optionally pageSize) and it derives the page count, the ellipsis-truncated range, and the “Showing 1–10 of 240” summary — or set pageCount explicitly. Every control lives inside one raised “paper rail” so the pager reads as a single object, and the active page is an accent pill that glides between numbers via Motion's layoutId. Opt into showSummary, showJumper (a go-to-page input), and pageSizeOptions + onPageSizeChange for an instant rows-per-page picker; flip on showProgress for a slim accent meter that tracks page ÷ count. Tune density with siblingCount / boundaryCount, toggle first/last jumps with showEdges, and pick a size. Controlled via page + onPageChange or uncontrolled via defaultPage. The exported paginationRange helper returns the raw item array if you want to render your own markup.