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.
Preview & playground
Edit the code — the preview updates live. Try changing props, text, or classes.
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 />)
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.
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.
function Demo() { const [page, setPage] = useState(5) return ( <Pagination page={page} onPageChange={setPage} pageCount={10} size="sm" showEdges={false} siblingCount={2} /> ) } render(<Demo />)
Installation
Copy the source into your project with the registry CLI:
$pnpm dlx shadcn@latest add @stacklyui/paginationOr install the package and import it:
$pnpm add @stacklyui/ui motionUsage
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.