Skip to main content

Pagination Controls

StorybookView in Storybook

Explore interactive examples and all component variations in our Storybook.

The PaginationControls component provides a comprehensive pagination interface with page numbers, navigation buttons, and item counters. Built with accessibility and usability in mind, it handles large datasets efficiently with smart page number truncation. Perfect for data tables, search results, and any interface displaying paginated content.

Basic Usage

Showing 1 to 10 of 100 results
...

Data Table Integration

User Management
IDNameEmailRole
1User 1user1@example.comAdmin
2User 2user2@example.comEditor
3User 3user3@example.comViewer
4User 4user4@example.comAdmin
5User 5user5@example.comEditor
Showing 1 to 5 of 47 results
...

Custom Counter Text

Default Counter

Showing 1 to 20 of 156 results
...

Custom Counter Text

Displaying items 1-20 from 156 total
...

No Counter

...

Large Dataset Example

Large Dataset Pagination

This example shows how the pagination handles large datasets with smart truncation. Notice how it shows ellipsis (...) to indicate hidden pages.

Showing 1 to 50 of 12500 results
...

Current page: 1

Total pages: 250

Items per page: 50

Search Results Integration

Search Results

Found 73 results

Search Result 1

This is the description for search result 1. It contains relevant information about the topic.

Documentation/result/1

Search Result 2

This is the description for search result 2. It contains relevant information about the topic.

Tutorial/result/2

Search Result 3

This is the description for search result 3. It contains relevant information about the topic.

Guide/result/3

Search Result 4

This is the description for search result 4. It contains relevant information about the topic.

Reference/result/4

Search Result 5

This is the description for search result 5. It contains relevant information about the topic.

Documentation/result/5

Search Result 6

This is the description for search result 6. It contains relevant information about the topic.

Tutorial/result/6

Search Result 7

This is the description for search result 7. It contains relevant information about the topic.

Guide/result/7

Search Result 8

This is the description for search result 8. It contains relevant information about the topic.

Reference/result/8
Showing 1 to 8 of 73 search results
...

Properties

PaginationControls

PropertyTypeDefaultDescription
currentPagenumber-The current active page number.
totalPagesnumber-Total number of pages available.
totalItemsnumber-Total number of items across all pages.
startIndexnumber-Zero-based start index of current page items.
endIndexnumber-Zero-based end index of current page items.
onPageChange(page: number) => void-Callback fired when a specific page is selected.
onPreviousPage() => void-Callback fired when previous button is clicked.
onNextPage() => void-Callback fired when next button is clicked.
showItemsCounterbooleantrueWhether to display the items counter text.
counterTextstring'Showing {{startIndex}} to {{endIndex}} of {{totalItems}} results'Template string for the counter text.
classNamestring-Additional CSS classes for the container.

Counter Text Variables

The counterText prop supports template variables that are automatically replaced:

VariableDescriptionExample Value
{{startIndex}}First item number on current page (1-based)21
{{endIndex}}Last item number on current page30
{{totalItems}}Total number of items156

Page Number Algorithm

The component uses smart truncation for large datasets:

  • Small datasets (≤7 pages): Shows all page numbers
  • Large datasets (>7 pages): Shows first page, ellipsis, current page ±1, ellipsis, last page
  • Current page context: Always shows 1-2 pages around the current page
  • Ellipsis indicators: Shows "..." when pages are hidden

Accessibility

The PaginationControls component includes comprehensive accessibility features:

  • Keyboard Navigation - Tab navigation through all interactive elements
  • Screen Reader Support - Proper ARIA labels and page announcements
  • Focus Management - Clear focus indicators on buttons
  • Disabled States - Previous/next buttons disabled at boundaries
  • Semantic HTML - Uses proper button elements with descriptive labels
  • Page Context - Current page clearly indicated visually and programmatically

Common Use Cases

The PaginationControls component is perfect for:

  • Data Tables - Navigate through large datasets efficiently
  • Search Results - Browse through search result pages
  • Product Catalogs - Navigate product listings in e-commerce
  • User Lists - Manage large user directories
  • Content Archives - Browse blog posts, articles, or documents
  • Admin Dashboards - Navigate through administrative data
  • API Results - Handle paginated API responses
  • File Browsers - Navigate through file listings

Best Practices

  1. Consistent Page Sizes - Use consistent items per page across your application
  2. Loading States - Show loading indicators during page transitions
  3. URL Synchronization - Sync current page with URL parameters when possible
  4. Mobile Optimization - Ensure pagination works well on small screens
  5. Performance - Implement virtual scrolling for very large datasets
  6. Error Handling - Handle edge cases like empty results gracefully
  7. Analytics - Track pagination usage to optimize page sizes
  8. Accessibility Testing - Test with screen readers and keyboard navigation