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:
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.
Prop | Type | Default | Description |
---|---|---|---|
className | string | - | Additional CSS classes |
children | React.ReactNode | - | PaginationContent component |
PaginationContent
Container for all pagination items, handles layout and spacing.
Prop | Type | Default | Description |
---|---|---|---|
className | string | - | Additional CSS classes |
children | React.ReactNode | - | PaginationItem components |
PaginationItem
Individual pagination item wrapper that handles proper spacing and alignment.
Prop | Type | Default | Description |
---|---|---|---|
className | string | - | Additional CSS classes |
children | React.ReactNode | - | PaginationLink, PaginationPrevious, PaginationNext, or PaginationEllipsis |
PaginationLink
Clickable page number or link with active state support.
Prop | Type | Default | Description |
---|---|---|---|
className | string | - | Additional CSS classes |
isActive | boolean | false | Whether this page is currently active |
size | "default" | "icon" | "icon" | Size variant for the link |
href | string | required | URL for the page |
children | React.ReactNode | - | Link content (page number, text) |
PaginationPrevious
Previous page navigation button with proper labeling.
Prop | Type | Default | Description |
---|---|---|---|
className | string | - | Additional CSS classes |
href | string | required | URL for the previous page |
PaginationNext
Next page navigation button with proper labeling.
Prop | Type | Default | Description |
---|---|---|---|
className | string | - | Additional CSS classes |
href | string | required | URL for the next page |
PaginationEllipsis
Visual indicator for omitted pages between ranges.
Prop | Type | Default | Description |
---|---|---|---|
className | string | - | Additional CSS classes |
Data attributes:
[aria-hidden]
: "true" (since it's decorative)- Uses More Horizontal icon from Lucide React
Keyboard Navigation
Key | Action |
---|---|
Tab | Move focus between pagination links |
Shift + Tab | Move focus to previous link |
Enter / Space | Navigate to focused page |
Home | Focus first page link (if implemented) |
End | Focus last page link (if implemented) |
Common Patterns
Pattern | Use Case | Implementation |
---|---|---|
Basic numbered | Simple page lists | Previous, 1, 2, 3, Next |
With ellipsis | Large page ranges | 1, 2, 3, ..., 10, Next |
Compact | Mobile layouts | Previous, Page X of Y, Next |
Infinite boundaries | No 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
Navigation Menu
A collection of links for navigating websites and React applications. Built with Radix UI NavigationMenu for keyboard navigation and screen reader accessibility.
Popover
Displays rich content in a portal, triggered by a button. Built for React applications with Next.js integration and TypeScript support.