Skip to content

Pagination

Introduction

The Pagination component provides a flexible, accessible, and highly customizable interface for navigating through pages of content. It supports multiple visual variants, sizes, shapes, alignment options, compact and expanded layouts, direct page jumping, and can be fully controlled via signals. Common use cases include blog lists, product catalogs, data tables, and search results.

Import

ts
import { Pagination } from '@odyssee/components';

LiveCodeEditor examples

Basic Pagination

Code Éditable
Résultat

Variants

Code Éditable
Résultat

Sizes

Code Éditable
Résultat

Shapes

Code Éditable
Résultat

Alignment

Code Éditable
Résultat

With Text Labels

Code Éditable
Résultat

Mini Pagination

Code Éditable
Résultat

With Jumper

Code Éditable
Résultat

Controlled Pagination

Code Éditable
Résultat

Use Case: Blog Posts Pagination

Code Éditable
Résultat

Props

PropTypeDefaultDescription
currentPagenumber | Signal<number>The current page (1-indexed).
totalPagesnumberTotal number of pages.
variant"default" | "bordered" | "bordered-group""default"Visual style of the pagination.
shape"default" | "pilled""default"Shape of the pagination buttons.
size"sm" | "md" | "lg""md"Size of the pagination buttons.
alignment"start" | "center" | "end""start"Alignment of the pagination component.
showPrevNextbooleantrueShow previous/next navigation buttons.
showPrevNextTextbooleanfalseShow text labels ("Previous"/"Next") on navigation buttons.
prevTextstring"Previous"Custom text for previous button.
nextTextstring"Next"Custom text for next button.
showEllipsisbooleantrueShow ellipsis when page numbers are truncated.
siblingCountnumber1Number of page buttons to show around current page.
showBoundariesbooleantrueShow first and last page buttons.
minibooleanfalseCompact pagination ("1 of 3" format).
showJumperbooleanfalseShow input for direct page jumping.
jumperTextstring"Go to"Text label for the jumper input.
showItemsPerPagebooleanfalseShow dropdown for items per page.
itemsPerPageOptionsnumber[][5, 8, 10]Options for items per page dropdown.
itemsPerPagenumber5Current items per page.
stretchedbooleanfalseStretched layout (space-between).
disabledbooleanfalseDisables the pagination.
onPageChange(page: number) => voidCallback fired when the page changes.
onItemsPerPageChange(itemsPerPage: number) => voidCallback fired when items per page changes.
classNamestringAdditional CSS classes for the root element.
idstringauto-generatedID for the pagination component.
styleobjectInline styles for the root element.
...restBaseComponentPropsAny other base props supported by Odyssee components.

Implementation notes

  • The component uses Pulse signals for controlled and uncontrolled usage.
  • Page numbers are dynamically generated based on totalPages, currentPage, and siblingCount.
  • Ellipsis and boundary pages are shown for large page counts.
  • Supports multiple variants (default, bordered, bordered-group) and shapes (default, pilled).
  • Mini mode displays a compact "X of Y" format.
  • Jumper input allows direct navigation to a specific page.
  • Items per page dropdown is available for advanced use cases.
  • All navigation logic is handled internally, with callbacks for external control.
  • Designed for both light and dark themes.

Accessibility

  • All navigation buttons are rendered as accessible <button> elements with proper ARIA labels.
  • The current page uses aria-current="page" for screen readers.
  • Ellipsis and boundary pages are keyboard navigable.
  • Jumper input is accessible and supports keyboard navigation.
  • Disabled states are visually and programmatically indicated.
  • Focus and hover states are clearly styled for usability.

Best practices

  • Use controlled mode (currentPage as signal + onPageChange) for full synchronization with your app state.
  • Choose the appropriate variant and size for your layout and design system.
  • Use mini mode for compact UIs or mobile contexts.
  • Enable the jumper for large datasets where direct navigation is useful.
  • Always provide clear feedback for disabled states and navigation limits.
  • Use items per page dropdown for data tables or catalogs with variable page sizes.

Released under the MIT License.