Skip to main content

Pagination

The Pagination component provides page navigation controls with support for first/last/next/previous buttons, dynamic page numbers, and a page size selector. It automatically adapts between desktop and mobile layouts and supports both LTR and RTL locales.

import { Pagination } from "tawuniya/components";

👉 View in Storybook

Props​

PropTypeDefaultDescription
paginationTotalnumber—Total number of items.
firstButtonLabelstring—Custom label for the "First" button.
lastButtonLabelstring—Custom label for the "Last" button.
prevButtonLabelstring—Custom label for the "Previous" button.
nextButtonLabelstring—Custom label for the "Next" button.
classNamestring—Custom classes.

Usage​

Basic Example​

<Pagination paginationTotal={200} />

With Custom Labels​

<Pagination
paginationTotal={100}
firstButtonLabel="<<"
lastButtonLabel=">>"
prevButtonLabel="Prev"
nextButtonLabel="Next"
/>

Features​

  • Responsive Layout:
    • Desktop → shows First and Last buttons.
    • Mobile → hides First and Last buttons for compactness.
  • Localization:
    • Adapts icons and labels for Arabic (rtl) and English (ltr).
  • Dynamic Page Numbers:
    • Automatically generates page numbers with ellipsis (...) when needed.
  • Page Size Selector:
    • Allows changing how many items per page (default: 10).

Notes​

  • Pagination state (page, pageSize, etc.) is managed internally by the hook usePaginationQuery.
  • Default page size options: 5, 10, 20, 30, 40, 50.