CraftUI

Pagination

Links to the previous, next and numbered pages.

Installation

npx shadcn@latest add @runqora/craft-pagination

Usage

import {
  Pagination,
  PaginationContent,
  PaginationItem,
  PaginationLink,
  PaginationNext,
  PaginationPrevious,
} from "@/components/craft/pagination";

<Pagination>
  <PaginationContent>
    <PaginationItem>
      <PaginationPrevious href="?page=1" />
    </PaginationItem>
    <PaginationItem>
      <PaginationLink href="?page=2" isActive>
        2
      </PaginationLink>
    </PaginationItem>
    <PaginationItem>
      <PaginationNext href="?page=3" />
    </PaginationItem>
  </PaginationContent>
</Pagination>;

Props

Prop

Type

Accessibility

  • It's a nav landmark named Pagination, with the links in a list.
  • The current page has aria-current="page" as well as its green color.
  • A disabled link has no destination and leaves the tab order, so there's never a link that goes nowhere.
  • On narrow screens, Previous and Next show only their arrows, and keep their names for screen readers.

Customization

These are plain links, and it renders on the server, so search engines can follow every page. To page through data without links, use buttons in a PaginationContent instead.

Dependencies

  • craft-button
  • shadcn's utils, and craft-theme

Source

On this page