Pagination

Pages through a long list: how many are showing, an optional rows-per-page choice, then previous, the pages around the current one with an ellipsis for each gap, and next. Built on ui-sdk's Pagination: the current page has aria-current, and previous and next stay focusable but disabled at the ends.

BetaReady to use. Its API can still change in a minor release; the changelog says when.

import { Pagination } from "@leap-crm/design-system";

Playground

Change a prop and the component follows. Its code is under Props.

Props

total
pageSize
itemName
siblings
disabled

Best practices

When to use it, and the rules that apply in particular places.

GuidancePractice
DoUse it under a long list or table where people jump to a place, like page 4 of a firm's contacts.
DoSet itemName so the count reads "Showing 1–25 of 312 contacts", and give each pagination on a page its own aria-label, like "Contacts pages".
DoWith pageSizeOptions, hold the size in state: pass it back as pageSize from onPageSizeChange and go back to page 1.
DoPass getHref when each page has its own URL, so a lawyer can reopen or share the page they were on.
Don'tDisable previous or next yourself at the ends. They already stay focusable but disabled, so keyboard users don't lose their place.

Props

PropTypeDefaultDescription
pagenumber—The current page, from 1. Pass it to control the pagination.
defaultPagenumber—The page it starts on, when uncontrolled.
onPageChange(page: number) => void—Runs with the page to show next, from 1.
total *number—How many items there are in all.
pageSizenumber25Items on a page.
pageSizeOptionsnumber[]—Offers a page-size choice with these sizes, like [25, 50, 100].
onPageSizeChange(pageSize: number) => void—Runs with the page size chosen. Go back to page 1 when it changes.
itemNamestring—What the items are, for "Showing 1–25 of 312 contacts".
getHref(page: number) => string—Makes each page a link, for pages with their own URL.
siblingsnumber1Pages shown either side of the current one before an ellipsis.
disabledboolean—Shows it as unavailable and stops it responding.
aria-labelstring"Pagination"Names the navigation, like "Contacts pages".
classNamestring—Classes added to the root element, merged with its own. Tokens only.

Code

What the playground shows, ready to copy.

import { Pagination } from "@leap-crm/design-system";

<Pagination total={240} />

Rows per page

pageSizeOptions adds the choice; changing it goes back to page 1.

Few pages, and links

Three pages show without ellipses. getHref makes every page a link, for lists whose pages have their own URL.

What the examples share

The imports and the scaffolding the examples above call. The scaffolding lives in this page, not in the library.

import { useState } from "react";

import { Pagination } from "@leap-crm/design-system";

function WithPageSize() {
  const [pageSize, setPageSize] = useState(25);
  const [page, setPage] = useState(1);
  return (
    <Pagination
      total={312}
      itemName="contacts"
      page={page}
      onPageChange={setPage}
      pageSize={pageSize}
      pageSizeOptions={[25, 50, 100]}
      onPageSizeChange={size => {
        setPageSize(size);
        setPage(1);
      }}
      aria-label="Contacts pages"
    />
  );
}

Keyboard

The keys it answers to. Tab moves between components, arrows move within them.

KeysWhat they do
EnterSpaceGo to the focused page.