@usevyre/react@usevyre/vue

Pagination

A page navigation control with smart ellipsis truncation. Automatically hides out-of-range page numbers and replaces them with dots while always keeping the first and last pages visible.


Basic

Fully controlled — provide page and onPageChange (React) orv-model (Vue).

Page 1 of 10

import { Pagination } from "@usevyre/react";

const [page, setPage] = useState(1);

<Pagination
  page={page}
  totalPages={10}
  onPageChange={setPage}
/>

Many pages with siblings

Use siblings to control how many page buttons appear around the current page. The component automatically inserts where pages are skipped.

Page 7 of 20 · siblings=2

{/* Show 2 page siblings on each side of the current page */}
<Pagination
  page={page}
  totalPages={20}
  onPageChange={setPage}
  siblings={2}
/>

With info label

Add showInfo to switch to a full-width row layout with aShowing x–y of total label on the left and controls on the right. Provide totalItems + pageSize for the exact range; omit them to fall back to Page x of y.

Showing 1–10 of 98
Showing 1–10 of 98
{/* Showing x–y of total, computed from totalItems + pageSize */}
<Pagination
  page={page}
  totalPages={totalPages}
  onPageChange={setPage}
  showInfo
  totalItems={98}
  pageSize={10}
/>

{/* Without edge buttons */}
<Pagination
  page={page}
  totalPages={totalPages}
  onPageChange={setPage}
  showInfo
  showEdges={false}
  totalItems={98}
  pageSize={10}
/>

Props

Props

PropTypeDefaultDescription
page / v-modelnumberCurrent page (1-indexed).
totalPagesnumberTotal number of pages.
onPageChange(page: number) => void(React) Called when the user navigates to a new page.
siblingsnumber1Number of page buttons shown on each side of the current page.
showEdgesbooleantrueShow first/last page jump buttons (⟪ / ⟫).
showInfobooleanfalseShow a 'Showing x–y of total' label on the left in a space-between row layout.
totalItemsnumberTotal record count. Used with pageSize to compute the x–y range in the info label.
pageSizenumberRecords per page. Used with totalItems to compute the x–y range.
class / classNamestringAdditional CSS class on the root element.