Pagination

Displays a pagination component that can be used to navigate through a list of items.

Overview

The Pagination component provides navigation controls for browsing through large sets of data or content, with support for page links, previous/next buttons, ellipsis for truncated ranges, and active state indicators.

Usage

import {
  Pagination,
  PaginationRoot,
  PaginationContent,
  PaginationLink,
} from "@tilt-legal/cubitt-components/primitives";

Basic Pagination

<PaginationRoot currentPage={1} totalPages={10}>
  {/* Pagination items will be automatically rendered */}
</PaginationRoot>

URL State Management

Using Cubitt's URL-state hooks, you can sync the pagination state with the URL, provide a paramName:

// Current page synced with ?page=3
<PaginationRoot
  currentPage={1}
  totalPages={20}
  paramName="page"
>
  {/* Pagination automatically handles URL sync */}
</PaginationRoot>

// Advanced options:
<PaginationRoot
  currentPage={1}
  totalPages={50}
  paramName="p"
  paramClearOnDefault={true}    // Remove param when page equals 1
  paramDebounce={200}           // Debounce URL updates
  onUrlValueChange={(page) => console.log('Page changed:', page)}
  maxVisiblePages={5}
  showFirstLast={true}
  showPrevNext={true}
>
  {/* Enhanced pagination with all features */}
</PaginationRoot>

Examples

URL State

Props

PaginationRoot

PropTypeDescription
currentPagenumberThe current active page number.
totalPagesnumberThe total number of pages.
onPageChange(page: number) => voidEvent handler called when the page changes.
paramNamestringURL parameter name for syncing state with URL. When provided, enables URL state management.
onUrlValueChange(page: number) => voidCallback when URL parameter value changes.
paramClearOnDefaultbooleanRemove URL param when page equals 1. Defaults to true.
paramDebouncenumberDebounce URL updates in milliseconds.
paramThrottlenumberThrottle URL updates in milliseconds.
showPrevNextbooleanWhether to show previous/next buttons. Defaults to true.
showFirstLastbooleanWhether to show first/last page buttons. Defaults to false.
maxVisiblePagesnumberMaximum number of page buttons to show. Defaults to 5.
classNamestringAdditional CSS classes to apply.

Pagination

PropTypeDescription
classNamestringAdditional CSS classes to apply.
...propsReact.HTMLAttributes<HTMLDivElement>All other div element props.

PaginationContent

PropTypeDescription
classNamestringAdditional CSS classes to apply.
...propsReact.HTMLAttributes<HTMLUListElement>All other ul element props.
PropTypeDescription
isActivebooleanWhether this page link is active.
size"default" | "sm" | "lg" | "icon"The size variant of the link.
classNamestringAdditional CSS classes to apply.
...propsReact.ComponentProps<typeof Link>All other link component props.

On this page