Pagination

Page-by-page navigation.

total is the number of pages. Use defaultPage when uncontrolled, or page with onChange for controlled mode. siblings sets how many neighbouring pages are visible around the current one; the rest collapse into an ellipsis. Set prevAriaLabel and nextAriaLabel for the previous and next buttons in the interface language.

Live example

Example controls

Usage

'use client';

import { Pagination } from '@prosazhin/pbcomponents';
import { useState } from 'react';

function Example() {
  const [page, setPage] = useState(1);
  return (
    <Pagination
      total={20}
      page={page}
      onChange={setPage}
    />
  );
}

Component API

PropType / variantsPurposeDefault
totalnumberNumber of pages.—
pagenumberCurrent page in controlled mode.—
defaultPagenumberInitial page when uncontrolled.1
onChange(page: number) => voidCalled when the page changes.—
siblingsnumberHow many neighbouring pages to show around the current one.1
size'xs' | 's'xs · sButton size.s
prevAriaLabelstringAccessible name of the previous button.Previous page
nextAriaLabelstringAccessible name of the next button.Next page
classNamestringClass of the root element.—

Native HTML attributes are accepted where the component renders the corresponding element. className props only affect styling.