On this page

InstallationUsageAnatomyPropspage, pageSize, totalonPageChangeonPageSizeChange and pageSizescountsummarynoteStatesFirst and last pageOne pageA short listNo resultsIn a card's footerAPI ReferenceAccessibilityRulesOpen questionsDecidedWhat others expose

Pagination

The pager under a list: how many results, how many rows a page, and Previous and Next around the page you are on. It holds no state, and it draws a control only when the list is long enough to use it. The Table draws it in its footer; no dashboard screen uses it yet.

The rows of a list
240 total results
RowsPage 1 of 10
1<Pagination2  page={page}3  pageSize={pageSize}4  total={240}5  onPageChange={setPage}6  onPageSizeChange={(size) => {7    setPageSize(size);8    setPage(1);9  }}10/>

Installation

import { Pagination } from "@catalog-dashboard/components";

Usage

<Pagination
  page={page}
  pageSize={pageSize}
  total={240}
  onPageChange={setPage}
  onPageSizeChange={(size) => {
    setPageSize(size);
    setPage(1);
  }}
/>
// A list drawn with the Table passes the same facts as its `pagination`; the Table places the pager.
<DataTable
  columns={columns}
  data={rows}
  getRowKey={(row) => row.id}
  pagination={{ page, pageSize, total, onPageChange: setPage, onPageSizeChange: setPageSize }}
/>

total is the list's whole count and the rows on screen are one page of it. For a list whose server pages it, both come from the server; the Table's inMemory pages a short list that arrives whole.

Anatomy

240 total results
RowsPage 3 of 10
  1. 1 · Count. How many results in all, or the summary in its place. 12px, secondary.
  2. 2 · Rows. The rows-per-page select, a 24px control named “Rows per page”.
  3. 3 · Previous. A 24px secondary button with its word. Disabled on the first page.
  4. 4 · Page. “Page 3 of 10”, in tabular figures.
  5. 5 · Next. Disabled on the last page. Previous, the page and Next leave together when there is one page.
PartSizeSpace
The row24px tall at least; body-3, 12px, secondary16px between the count and the controls
Rows select24px (xs)6px after the word “Rows”
Previous, Next24px (xs), secondary8px to the page text; 12px after the select

Props

page, pageSize, total

The three facts it draws from. page counts from 1, and the number of pages is total over pageSize, rounded up. It holds no state: whoever renders it keeps the page.

240 total results
Page 1 of 10
1const [page, setPage] = useState(1);2 3<Pagination page={page} pageSize={25} total={240} onPageChange={setPage} />

onPageChange

With it, Previous, the page and Next show while there is more than one page. Without it there is no pager.

240 total results
Page 1 of 10
240 total results
1<Pagination page={1} pageSize={25} total={240} onPageChange={setPage} />2<Pagination page={1} pageSize={25} total={240} />

onPageSizeChange and pageSizes

With onPageSizeChange, the rows-per-page select shows while some size on offer gives the list a second page; it does not leave with the pager. pageSizes is what it offers: 25, 50 and 100 unless set. The component does not change the page when the size changes: the caller does (the Table goes back to page 1).

240 total results
RowsPage 1 of 24
1<Pagination2  page={page}3  pageSize={pageSize}4  total={240}5  pageSizes={[10, 20, 50]}6  onPageChange={setPage}7  onPageSizeChange={(size) => {8    setPageSize(size);9    setPage(1);10  }}11/>

count

The count at the left, “240 total results”. On by default; count={false} leaves it out.

Page 1 of 10
1<Pagination page={page} pageSize={25} total={240} count={false} onPageChange={setPage} />

summary

What stands in the count's place while a list has something more pressing to say there. It is a polite live region, so a change is announced. The Table does not use it: its selection reads in the bar's place, and “Select all 240” follows the total as the note.

25 of 240 selected
Page 1 of 10
1<Pagination2  page={page}3  pageSize={25}4  total={240}5  onPageChange={setPage}6  summary={7    <>8      25 of 240 selected9      <Button color="primary" emphasis="link" size="xs">Select all 240</Button>10    </>11  }12/>

note

What follows the count, after a dot: a line about the list as a whole. The Table puts “Select all 240” there once the whole page is checked, then the list's own note. Short of room it goes under the count.

240 total results20 hidden by filters·
Page 1 of 10
1<Pagination2  page={page}3  pageSize={25}4  total={240}5  onPageChange={setPage}6  note={<FilterHiddenNote hidden={20} onClear={clearFilters} />}7/>

States

First and last page

Previous is disabled on the first page and Next on the last. Both stay where they are.

240 total results
Page 1 of 10
240 total results
Page 10 of 10
1<Pagination page={1} pageSize={25} total={240} onPageChange={setPage} />2<Pagination page={10} pageSize={25} total={240} onPageChange={setPage} />

One page

With one page, the page and its two buttons are not drawn. The count stays, and so does the rows select: 25 a page would bring a second page back. Pick 50 here: the pager eases out over 200ms, and back in at 25. It cuts under reduced motion.

40 total results
RowsPage 1 of 2
1<Pagination page={page} pageSize={pageSize} total={40} onPageChange={setPage} onPageSizeChange={setPageSize} />

A short list

5 results fit one page at 25, 50 and 100: no size on offer gives a second page, so the rows select and the pager are not drawn. The count stays, and a note with it. The page size the reader chose is kept, only not shown.

5 total results
Page 1 of 1
1<Pagination page={1} pageSize={50} total={5} onPageChange={setPage} onPageSizeChange={setPageSize} />

No results

Alone it reads “0 total results”. A Table with no rows draws no footer at all.

0 total results
Page 1 of 1
1<Pagination page={1} pageSize={25} total={0} onPageChange={setPage} />

In a card's footer

Where the Table puts it: the CardFooter of the card that holds the rows, across its width.

The rows of a list
240 total results
RowsPage 1 of 10
1<Card>2  {rows}3  <CardFooter>4    <Pagination page={page} pageSize={pageSize} total={240} onPageChange={setPage} onPageSizeChange={setPageSize} className="w-full" />5  </CardFooter>6</Card>

API Reference

Besides these, every prop of a <div> except children.

PropTypeDefaultDescription
pagenumber—The page shown, from 1.
pageSizenumber—How many rows a page holds.
totalnumber—How many rows there are in all. Left out for a list paged by cursor, which knows no total: then there is no count and no page of pages.
hasNextbooleanfalseWith no total: whether there is a page after this one. Previous and Next show, at the right, while there is another page either way; Previous is on from page 2, Next while this is true. The rows-per-page select shows with onPageSizeChange.
onPageChange(page: number) => void—With it, Previous, the page and Next show, while there is more than one page.
onPageSizeChange(size: number) => void—With it, the rows-per-page select shows, while some size on offer gives the list a second page.
pageSizesreadonly number[][25, 50, 100]The sizes the select offers.
countbooleantrueThe count at the left, “240 total results”.
summaryReactNode—What stands in the count’s place. Announced politely when it changes.
noteReactNode—What follows the count, after a dot: a line about the list as a whole (“20 hidden by filters · Clear filters”). Short of room it goes under the count.

Accessibility

KeyDoes
TabMoves through what is there, in reading order: a link in the summary, the rows select, Previous, Next. A disabled button is skipped.
Enter, SpaceOn Previous or Next, goes to that page. On the select, opens it.
↑ ↓In the open select, moves through the sizes; Enter picks one, Esc closes it.

The count is a polite live region: a new total, or a new summary, is announced. The select is named “Rows per page”. With one page the pager is inert, so Tab skips it and a screen reader does not find it.

A page change itself is not announced, and the pager is not a named landmark: both are open questions below. Not checked: a screen reader, touch, Safari and Firefox.

Rules

Open questions

The total, or the range you are looking at?

Open
Ours

“240 total results” at the left, “Page 3 of 10” at the right.

Other systems

Carbon shows the range of items on screen beside its rows-per-page select. Atlassian and Primer show page numbers and no total.

Should a page change be announced?

Open
Ours

The count is announced when it changes. “Page 3 of 10” is not.

Other systems

Polaris puts its label in a polite live region. Primer and Atlassian put the pager in a named navigation landmark and mark the current page (aria-current); Primer also moves focus to the start of the new content when it is swapped in place.

Buttons, or links with an address?

Open
Ours

Previous and Next are buttons. Whether a list keeps its page in the address is the list's: the audit log does, today.

Other systems

shadcn and Primer draw each page as a link, and Primer says every page should have a URL. Carbon and shadcn's data table use buttons. Polaris takes either a URL or a handler.

Who goes back to page 1?

Open
Ours

The pager holds no state. The Table goes back to page 1 when the page size changes; on a new sort or filter, the page does it.

Other systems

Shopify's guidance: reset to the first page whenever search, filters or sorting change, and keep the page in the address.

Where the pager sits

Open
Ours

The Table puts it in its card's footer.

Other systems

Carbon: directly under its table, not stacked above it. Primer: at the end of the page content. Atlassian: at the bottom of the page.

Decided

12 total results
Page 1 of 1
Do12 results fit one page at every size on offer: the count alone.
12 total resultsPage 1 of 1
Don’t“Page 1 of 1” between two disabled buttons.

The count always; a paging control only when it can do something

The component does both by itself: it leaves the pager out for one page, and the rows select out when no size on offer gives a second page. The count and the select are props (count, onPageSizeChange), so a list that follows the rule keeps the first on and passes the second.

240 total results20 hidden by filters·
RowsPage 1 of 10
DoAt 360px: Previous and Next are their chevrons, and every part is still there.

Short of room it gives way in steps, and nothing overlaps or is cut

Decided with the designer on the Table's footer. First Previous and Next drop their words and become icon buttons, named “Previous page” and “Next page”. Then the left text takes two lines, the count over the note. Last it takes a row of its own over the controls, both starting at the left. The steps are measured, not set at fixed widths.

What others expose

What shadcn, Atlassian, Primer, Carbon and Polaris have that ours does not. Polaris's rows are from its public repository (its site redirects elsewhere). Base UI has no pagination. Nothing here is decided for us, and nothing was added: “Ours differs” says what ours does instead, “Ask” is a question for the designer.

They haveWhoOursWhy
Numbered page links, with an ellipsis for the gapshadcn, Atlassian, Primer, CarbonOurs differsOurs writes “Page 3 of 10” between Previous and Next.
First and last buttonsshadcn’s data tableAskOurs has Previous and Next only.
The range of items on screenCarbonAskOurs shows the total at the left and the page at the right. See the open question.
Pick the page from a selectCarbonAskOurs has no way to jump to a page.
Next and Previous with no known totalPolaris (hasNext, hasPrevious)AskOurs needs a total to know the last page, so a list paged by cursor with no count cannot use it as built.
Each page as a link, with an addressshadcn, Primer (hrefBuilder), Polaris (nextURL)AskOurs are buttons. See the open question.
A navigation landmark around the pager, with a nameAtlassian, Primer, PolarisAskOurs is a plain row. See the open question.
The whole pager disabled at onceAtlassian (isDisabled)AskOurs disables Previous and Next only at the ends.
Arrows instead of the wordsCarbon, PolarisOurs differsOurs writes Previous and Next, and short of room draws each as its small chevron alone, named “Previous page” and “Next page”. shadcn shows an arrow and the word, and hides the word on a narrow screen.
Parts that hide on a narrow screenPrimer (showPages per breakpoint), shadcn, CarbonOurs differsOurs keeps every part and gives way in steps, measured: Previous and Next become icon buttons, then the left text takes two lines, then a row of its own over the controls.
Keyboard shortcuts for next and previousPolaris (nextKeys, previousKeys)Ours differsOurs has none. Shopify’s newer guidance says to remove them in most apps.
Words that can be replacedAtlassian, shadcn, PolarisAsk“Previous”, “Next”, “Rows” and “total results” are written in the component.
Sizes, to match a table’s row heightCarbonOurs differsOurs is one size: 24px controls, 12px text.
Keeping its own page; custom page itemsAtlassian (defaultSelectedIndex, components), Primer (renderPage)Ours differsOurs holds no state and has no page items.
Catalog
Foundations
  • Overview
  • Tokens
  • Token usage
  • Typography
  • Icons
Atoms
  • Avatar
  • Badge
  • Button
  • Checkbox
  • Color picker
  • Copy button
  • Icon tooltip
  • Inline code
  • Input
  • Hint
  • Kbd
  • Loader
  • Native select
  • Progress bar
  • Progress ring
  • Radio
  • Select
  • Status dot
  • Switch
  • Text link
  • Textarea
  • Tooltip
  • Truncate
Molecules
  • Accordion
  • Activity chart
  • AI elements
  • Alert
  • Button group
  • Card
  • Code block
  • Combobox trigger
  • Command
  • Context switcher
  • Dropdown menu
  • Empty state
  • Field
  • Field group
  • Filter chip
  • Flow
  • Icon picker
  • Metric card
  • Modal
  • Modal confirmation
  • Pagination
  • Popover
  • Scroll area
  • Sidebar
  • Table
  • Tabs
  • Toggle group
LibraryPublished release