Skip to content

← All components

Navigation and interaction

Pagination

Previous, numbered, and next page navigation.

Live example

Usage

Each example includes the complete adapter-specific parameter reference. Copy it as a starting point, then remove options your use case does not need.

React

tsx
import { Pagination } from "@cofob/design-system-react";

/**
 * Complete Pagination parameter reference.
 * @param page/currentPage
 *   type: number
 *   required
 *   example: 3
 * @param totalPages/items
 *   type: number (Svelte) | PaginationItem[] (React)
 *   required
 *   example: 12 / {items}
 * @param previousHref/nextHref
 *   type: string (React)
 *   default: —
 *   example: "/guide"
 * @param onPageChange
 *   type: (page: number) => void
 *   default: —
 *   example: {handlePageChange}
 * @param label
 *   type: string | renderable content
 *   default: "Pagination"
 *   example: "Accessible label"
 * @param nav attributes
 *   type: native element attributes
 *   default: —
 *   example: class / style / aria-* / data-*
 */
export function PaginationExample() {
  return (
    <Pagination currentPage={1} items={items} />
  );
}

Svelte

svelte
<script lang="ts">
  import { Pagination } from "@cofob/design-system-svelte";

  // Complete Pagination parameter reference.
  // page/currentPage
  //   type: number
  //   required
  //   example: 3
  // totalPages/items
  //   type: number (Svelte) | PaginationItem[] (React)
  //   required
  //   example: 12 / {items}
  // getHref
  //   type: (page: number) => string (Svelte)
  //   default: —
  //   example: "/guide"
  // siblingCount
  //   type: number (Svelte)
  //   default: 1
  //   example: 2
  // onPageChange
  //   type: (page: number) => void
  //   default: —
  //   example: {handlePageChange}
  // label
  //   type: string | renderable content
  //   default: "Pagination"
  //   example: "Accessible label"
  // nav attributes
  //   type: native element attributes
  //   default: —
  //   example: class / style / aria-* / data-*
</script>

<Pagination bind:page totalPages={12} />

HTML

html
<!--
  Complete Pagination parameter reference.
  page/currentPage
    type: number
    required
    example: 3
  totalPages/items
    type: number (Svelte) | PaginationItem[] (React)
    required
    example: 12 / {items}
  previousHref/nextHref
    type: string (React)
    default: —
    example: "/guide"
  getHref
    type: (page: number) => string (Svelte)
    default: —
    example: "/guide"
  siblingCount
    type: number (Svelte)
    default: 1
    example: 2
  onPageChange
    type: (page: number) => void
    default: —
    example: {handlePageChange}
  label
    type: string | renderable content
    default: "Pagination"
    example: "Accessible label"
  nav attributes
    type: native element attributes
    default: —
    example: class / style / aria-* / data-*
-->
<nav class="cf-pagination" aria-label="Pagination">…</nav>

<script type="module">
  import { initDesignSystem } from "@cofob/design-system-css";

  const designSystem = initDesignSystem(document);
  window.addEventListener("pagehide", () => designSystem.destroy(), { once: true });
</script>

Parameters

Adapter differences are explicit. Native element attributes are forwarded in React and Svelte and can be written directly in HTML.

ParameterTypeDefaultAdaptersExampleDescription
page/currentPagerequirednumberrequiredReact · Svelte · HTML3Current page; bindable in Svelte and controlled in React.
totalPages/itemsrequirednumber (Svelte) | PaginationItem[] (React)requiredReact · Svelte · HTML12 / {items}Defines the page range in Svelte or explicit navigation items in React.
previousHref/nextHrefstring (React)React · HTML"/guide"Explicit React destinations for adjacent pages.
getHref(page: number) => string (Svelte)Svelte · HTML"/guide"Builds Svelte page links without coupling to a router.
siblingCountnumber (Svelte)1Svelte · HTML2Number of page links around the active Svelte page.
onPageChange(page: number) => voidReact · Svelte · HTML{handlePageChange}Runs before client-side page navigation.
labelstring | renderable content"Pagination"React · Svelte · HTML"Accessible label"Visible or accessible name, depending on the component.
nav attributesnative element attributesReact · Svelte · HTMLclass / style / aria-* / data-*Forwards native class/style, accessibility, event, and data attributes to the root element.