Overview
ThePagination component provides navigation controls for paginated content. It displays the current page number and total pages in a “X de Y” format (e.g., “1 de 5”), along with four navigation buttons: first page, previous page, next page, and last page. The component automatically calculates the total number of pages based on your data length and items per page.
Basic Usage
Examples
Simple Pagination
Controlled Pagination
With API Data Fetching
With Custom Styling
Different Page Sizes
Props
Total number of items to paginate. This is used along with
rowsPerPage to calculate the total number of pages.Number of items to display per page. The component divides
length by this value to determine total pages (rounded up).Initial or controlled page index (0-based). The first page is 0, second page is 1, etc.
Callback fired when the page changes. Receives the new page index (0-based) as its argument.
Custom CSS styles to apply to the container element.
Navigation Buttons
The component includes four navigation buttons:- First Page (
ChevronFirsticon): Jumps to page 0 - Previous Page (
ChevronLefticon): Goes back one page - Next Page (
ChevronRighticon): Goes forward one page - Last Page (
ChevronLasticon): Jumps to the last page
- First/Previous buttons: When on the first page (
start === 0) - Next/Last buttons: When on the last page (
start === totalPages - 1)
Styling
The pagination component uses:- Container: Flexbox layout with centered alignment
- Icon buttons: 26px × 26px circular hover areas
- Border radius: 42px (fully rounded)
- Hover background:
Color.background.soft - Active icon color:
Color.text.full - Disabled icon color:
Color.text.low - Text margin: 12px horizontal spacing
- Current page display: Bold font weight
Page Display Format
The component displays the current page in Spanish format:- First number: Current page (1-based for display)
- “de”: Spanish for “of”
- Second number: Total number of pages
font-weight: 700).
Accessibility
- Container has
role="pagination"for semantic meaning - Individual buttons have descriptive role attributes:
role="first-arrow"role="left-arrow"role="right-arrow"role="last-arrow"
- Cursor changes to
autowhen buttons are disabled - Visual feedback through color changes and hover states
TypeScript
Best Practices
- Always use 0-based indexing for the
startprop - Update your data display in the
onChangecallback - Keep
rowsPerPageconsistent with your data fetching strategy - Consider adding a page size selector for better UX
- Reset to page 0 when applying filters or changing page size
- Ensure
lengthis updated when your dataset changes - Use the controlled
startprop for predictable behavior - Display loading states while fetching new page data
Calculation Details
The component calculates total pages using:- 100 items ÷ 10 per page = 10 pages
- 95 items ÷ 10 per page = 10 pages (rounded up)
- 237 items ÷ 25 per page = 10 pages (rounded up from 9.48)