Pagination
Moves people between pages of a long list or table.
import { Pagination } from '@halo-ds/react';
When to use it
Use pagination when results are split into pages and people need to jump, compare or come back to a place. Page item is one page number; Pagination puts page items between Previous and Next buttons, or shows a compact "Page 1 of 10" for tight spaces.
Do
- Show the current page clearly, with Selected.
- Disable Previous on the first page and Next on the last.
- Keep the same number of items in the row as people move.
- Scroll back to the top of the list when the page changes.
Don't
- Show every page of a long list; use "…" instead.
- Hide Previous and Next; disable them instead.
- Use pagination for a few items that fit on one page.
- Reset to page 1 when people only sort; keep their place.
Pagination or Load more?
Both split long lists. Pick by whether people need to find their place again.
- Pagination: Tables, search results and admin lists. People can jump to a page, share it and come back to it. Shows how much there is in total.
- Load more: Feeds and galleries that people browse from the top. A Button at the end adds the next batch to the list. Avoid endless scrolling where a footer needs to be reached.
Props
Pagination props
| Prop | Type | What it does | ||
|---|---|---|---|---|
pageCount (required) | number | Number of pages. | ||
page | `number \ | undefined` | The current page, starting at 1. | |
defaultPage | `number \ | undefined` | ||
onPageChange | `((page: number) => void) \ | undefined` | ||
variant | `"numbers" \ | "compact" \ | undefined` | numbers shows page buttons; compact shows "Page 2 of 10" between arrows. Figma: Type. |
size | `"sm" \ | "md" \ | undefined` | Figma: Size. |
siblings | `number \ | undefined` | Pages shown on each side of the current one before an ellipsis. | |
aria-label | `string \ | undefined` | Screen reader name for the navigation landmark. | |
classNames | `Partial<Record<PaginationPart, string>> \ | undefined` | Extra class names for the parts inside the component, by part name, like { header: 'my-header' }. | |
styles | `Partial<Record<PaginationPart, CSSProperties>> \ | undefined` | Inline styles for the parts inside the component, by part name, like { footer: { gap: 4 } }. |
It also takes the usual HTML attributes for its element.
Examples
Overview
import { Pagination } from '@halo-ds/react';
export default function Example() {
return (
<div style={{ display: 'grid', gap: 24, justifyItems: 'center' }}>
<Pagination pageCount={12} defaultPage={4} />
<Pagination pageCount={12} defaultPage={4} variant="compact" />
</div>
);
}
In the middle
A long range collapses with "..." on both sides of the current page.
import { Pagination } from '@halo-ds/react';
export default function Demo() {
return <Pagination pageCount={20} defaultPage={9} />;
}
Small
The small size, used in table footers.
import { Pagination } from '@halo-ds/react';
export default function Demo() {
return <Pagination pageCount={10} defaultPage={1} size="sm" />;
}
More: https://halodesignsystem.dev/components/pagination