Pagination

React Pagination components are used to navigate through large sets of content split across multiple pages. They are commonly used in tables, search results, and content listings.

This Pagination component is built with React and styled using Tailwind CSS. It supports different layouts for page buttons, previous and next controls, and automatic ellipsis handling.

pagination

Installation

Install the component using the Tailgrids CLI.

npx @tailgrids/cli add pagination

Usage

Import the component and control the active page using state.

import { Pagination } from "@/registry/core/pagination";

export default PaginationExample = () => (
  <Pagination
    currentPage={2}
    totalPages={10}
    onPageChange={p => console.log(p)}
  />
);

Examples

Compact Variant

Use the compact variant for a minimal style, often suited for smaller sections or footers.

pagination

Full Side Layout

This is the default layout, showing both the icon and the text label ("Previous"/"Next") for side buttons.

pagination

Label-Only Side Layout

Shows only the text label ("Previous"/"Next") on desktop, but hides it on mobile to save space.

pagination

Icon-Only Side Layout

Uses icons only for previous and next buttons.

pagination

Mobile Preview

The pagination component is fully responsive, seamlessly adapting its layout and controls to ensure a consistent experience across various devices and screen sizes.

Page 1 of 10

API Reference

Pagination

PropTypeDefaultDescription
currentPagenumber-The currently active page number (1-based index).
totalPagesnumber-The total number of available pages.
onPageChange(page: number) => void-Callback function triggered when a page button is clicked.
variant'default', 'compact''default'Overall pagination style.
sideLayout'full', 'label', 'icon''full'Controls the appearance of the "Previous" and "Next" buttons.

Accessibility

  • Uses semantic <nav> with role="navigation" and aria-label="Pagination".
  • All interactive page buttons and side buttons have descriptive aria-label attributes.
  • The currently active page is indicated using aria-current="page".
  • Disabled states on side buttons clearly communicate when no previous or next page is available.