Join our Discord Community

Pagination

Navigation component for splitting large datasets across multiple pages. Built for React applications with Next.js integration and TypeScript support.

You know those number lists at the bottom of search results or blog posts? That's pagination - it breaks up big lists into manageable chunks so users don't get overwhelmed scrolling through hundreds of items.

Complete pagination with navigation

Full-featured pagination with previous, next, and page numbers:

Loading component...

Built with semantic HTML and proper ARIA labels, this free open source React component gives you all the pagination patterns users expect from modern web applications.

npx shadcn@latest add pagination

Why pagination works better than infinite scroll

Sometimes you need pagination instead of infinite scroll - here's when it shines:

  • Predictable navigation - Users can jump to specific pages or sections
  • SEO friendly - Each page gets its own URL for better indexing
  • Memory efficient - Loads only what's needed, perfect for large datasets
  • Keyboard accessible - Tab navigation, arrow keys, and screen readers
  • Performance focused - No endless DOM growth with thousands of items
  • User control - People can bookmark pages or share specific results

Perfect for data-heavy applications

Works best when you're building applications with large datasets - admin panels, search results, product catalogs, user directories. Pagination gives users that structured browsing experience they need for finding specific content.

Drop it into any React or Next.js project where you want users to navigate through content systematically instead of endlessly scrolling.

Next.js Integration

By default the <PaginationLink /> component renders an <a /> tag. For Next.js applications, update your pagination component to use Next.js Link:

import Link from "next/link"

type PaginationLinkProps = {
  // ... other props
} & React.ComponentProps<typeof Link>

const PaginationLink = ({ className, isActive, size = "icon", ...props }) => (
  <PaginationItem>
    <Link
      aria-current={isActive ? "page" : undefined}
      className={cn(
        // ... styling classes
      )}
      {...props}
    />
  </PaginationItem>
)

This gives you client-side navigation with Next.js routing while maintaining all the accessibility features.

API Reference

Pagination

The root container that provides semantic structure for pagination controls.

PropTypeDefaultDescription
classNamestring-Additional CSS classes
childrenReact.ReactNode-PaginationContent component

PaginationContent

Container for all pagination items, handles layout and spacing.

PropTypeDefaultDescription
classNamestring-Additional CSS classes
childrenReact.ReactNode-PaginationItem components

PaginationItem

Individual pagination item wrapper that handles proper spacing and alignment.

PropTypeDefaultDescription
classNamestring-Additional CSS classes
childrenReact.ReactNode-PaginationLink, PaginationPrevious, PaginationNext, or PaginationEllipsis

Clickable page number or link with active state support.

PropTypeDefaultDescription
classNamestring-Additional CSS classes
isActivebooleanfalseWhether this page is currently active
size"default" | "icon""icon"Size variant for the link
hrefstringrequiredURL for the page
childrenReact.ReactNode-Link content (page number, text)

PaginationPrevious

Previous page navigation button with proper labeling.

PropTypeDefaultDescription
classNamestring-Additional CSS classes
hrefstringrequiredURL for the previous page

PaginationNext

Next page navigation button with proper labeling.

PropTypeDefaultDescription
classNamestring-Additional CSS classes
hrefstringrequiredURL for the next page

PaginationEllipsis

Visual indicator for omitted pages between ranges.

PropTypeDefaultDescription
classNamestring-Additional CSS classes

Data attributes:

  • [aria-hidden]: "true" (since it's decorative)
  • Uses More Horizontal icon from Lucide React

Keyboard Navigation

KeyAction
TabMove focus between pagination links
Shift + TabMove focus to previous link
Enter / SpaceNavigate to focused page
HomeFocus first page link (if implemented)
EndFocus last page link (if implemented)

Common Patterns

PatternUse CaseImplementation
Basic numberedSimple page listsPrevious, 1, 2, 3, Next
With ellipsisLarge page ranges1, 2, 3, ..., 10, Next
CompactMobile layoutsPrevious, Page X of Y, Next
Infinite boundariesNo first/last...3, 4, 5, 6, 7...

Build pagination that guides users

  • Show page context - Current page, total pages, or item ranges
  • Handle edge cases - Disable previous on first page, next on last page
  • Use meaningful labels - "Next page", "Previous page" for screen readers
  • Keep it responsive - Fewer numbers on mobile, more on desktop
  • Test with real data - Make sure it works with 5 pages and 500 pages
  • Consider loading states - Show feedback when navigating between pages
  • Preserve user state - Maintain filters, search terms across page changes
  • Use proper URLs - Each page should have its own addressable URL