Pagination

Documentation and examples for the Pagination component.

When To Use

  • When it will take a long time to load/render all items.
  • If you want to browse the data by navigating through pages.

Example Usage

The Pagination component handles generating page links based on the current page, total pages, and a base URL.

With Base URL

You can provide a `baseUrl` prop to prefix all generated page links. For example, setting `baseUrl="/blog"` will generate links like `/blog?page=2`. If no `baseUrl` is provided, it uses `?page=X`.

Large Number of Pages

When there are many pages, the component automatically truncates the middle pages with ellipses to maintain a compact UI.

Variants

The Pagination component supports `button` (default), `dots`, and `lines` variants, which are especially useful for carousels.

API Reference

Property
Description
Type
Default

currentPage

The current active page. number 1

totalPages

The total number of pages available. number 5

baseUrl

The base URL to prefix to generated links. string ''

variant

The visual style of the pagination. 'button' | 'dots' | 'lines' 'button'

class

Additional CSS classes for custom styling. string -