cnippet/ui
  1. ui
  2. navigation
  3. pagination

navigation

Pagination

A pagination with page navigation, next and previous links. Built with Base UI and Tailwind CSS. Copy-paste ready.

Installation

Usage

Anatomy

Good to know

  • This is markup and styling only. It doesn't track the current page or calculate page numbers; your code decides which links to render.
  • Mark the current page with isActive. It sets aria-current="page" and the outline style.
  • Links are plain <a> elements. For client-side routing, use render={<Link href="?page=2" />} on PaginationLink, PaginationPrevious or PaginationNext.
  • Below the sm breakpoint, Previous and Next show only their arrow icons.
  • PaginationEllipsis is hidden from screen readers but includes "More pages" as screen-reader text.

API Reference

Pagination

Root <nav> element with aria-label="pagination".

PaginationContent

<ul> flex row holding all pagination items.

PaginationItem

<li> wrapper for each pagination element.

Navigable page link.

PaginationPrevious

Pre-built previous-page link with a ChevronLeft icon and "Previous" label.

PaginationNext

Pre-built next-page link with a ChevronRight icon and "Next" label.

PaginationEllipsis

<span> placeholder for collapsed page ranges. Renders a MoreHorizontal icon.

Examples

Without Labels

Removes the "Previous" and "Next" text labels, showing only arrow icons for a more compact pagination bar.

With Hover Effect

Adds a background highlight on hover for each page number link to improve click affordance.

With Circle Buttons

Renders each page number as a circular button for a rounder, more icon-centric pagination style.

With Go-To-Page Input

Adds a text input that lets users jump directly to any page number without clicking through sequentially.

In Card

Wraps pagination controls inside a Card alongside a row count indicator, suitable for table footers.

With Arrows Buttons

Uses larger arrow-only buttons with no visible page numbers for simple previous/next browsing.

Page Info Centered

Centers a "Page X of Y" text label between the previous and next controls.

Page Info Left

Aligns the page info string to the left with the previous/next controls pushed to the right.

Outline Buttons

Renders page buttons with an outline border variant instead of the default ghost style for a more defined appearance.

With Page Select

Adds a Select for choosing the current page and dedicated first/last page buttons for large datasets.

Numbered With Input

Combines numbered page links with an inline jump-to input field for large paginated datasets.

A full-featured pagination bar including total count, ellipsis collapse, and a rows-per-page select dropdown.

Controlled with Ellipsis

A fully controlled pagination component with smart window collapse — shows first/last pages and a sliding window of adjacent pages, with ellipsis and a live "Showing X–Y of N" results count.

Mini Pill

A compact rounded-full border wrapping previous/next arrows around a centered "X of Y" counter — minimal footprint for tight layouts.

Older / Newer Navigation

Blog-style cursor navigation with "← Newer posts" and "Older posts →" links instead of numbered pages — ideal for chronological feeds.

Controlled with Smart Ellipsis

A useState-driven pagination that recomputes the visible page window on every click, collapsing distant pages into PaginationEllipsis automatically.

Results Summary

A two-column bar with "Showing 41–60 of 230 results" on the left and compact prev/next arrows flanking a "3 / 12" counter on the right.

Loading State

The entire pagination bar is dimmed with pointer-events-none opacity-40 and overlaid with a spinning Loader2Icon to communicate that results are being fetched.