suiss/ui · Component
Pagination
Navigation links for moving between pages of content, such as table results.
Pagination is an open-source component from suiss/ui for React. The @esuiss/ui CLI copies its source into your project, so you own the code.
Pagination is a set of link primitives you compose around your own page state. Pagination is the nav landmark. Inside it, PaginationContent is a list of PaginationItem entries, each holding a PaginationLink, PaginationPrevious, PaginationNext, PaginationFirst, PaginationLast or PaginationEllipsis.
For compact toolbars, PaginationGroup joins arrow links into one segmented control, PaginationInput lets the user type a page number, and PaginationSummary shows a range such as 6–10 / 62. The component does not calculate page ranges; you decide which links to render.
Installation
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
Usage
Composition
Use the following composition to build a Pagination:
Examples
Compact
A PaginationInput for the page number with previous and next arrows joined in a PaginationGroup. Set text="" on PaginationPrevious or PaginationNext for icon-only arrows. The example clamps typed values to the valid range.
Rows per page
A rows-per-page select, a PaginationSummary with the current range, and PaginationFirst, PaginationPrevious, PaginationNext and PaginationLast arrows.
With ellipsis
Use PaginationEllipsis on both sides of the current page to shorten a long page range.
Custom labels
Use the text prop to relabel the previous and next links Newer and Older.
Large links
Set size="icon" on PaginationLink for larger page links.
Accessibility
Paginationrenders anavwitharia-label="pagination".- The active
PaginationLinkgetsaria-current="page". - Arrow links have built-in accessible names:
Go to previous page,Go to next page,Go to first pageandGo to last page. Customtexton previous or next replaces the name. - The
PaginationEllipsisicon is hidden from assistive technology, and its visually hidden text,More pages, is read instead. PaginationGrouphasrole="group".PaginationInputhas no built-in label; associate one withhtmlFororaria-label.
API Reference
Pagination
The nav landmark that contains the pagination controls.
Also accepts the props of React.ComponentProps<"nav">.
PaginationContent
The list that holds the pagination items.
Also accepts the props of React.ComponentProps<"ul">.
PaginationItem
A list item wrapper for one link or ellipsis.
Also accepts the props of React.ComponentProps<"li">.
PaginationLink
A page link styled as a button, highlighted when active.
| Prop | Type | Default |
|---|---|---|
isActive | boolean | - |
size | "default" | "xs" | "sm" | "lg" | "xl" | "form" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | "icon-xl" | "icon-sm" |
Also accepts the props of React.ComponentProps<"a">.
Links render as a elements, so pass href for real routes, or href="#" with an onClick that calls preventDefault() for client-side state. isActive marks the current page with aria-current="page" and the secondary button variant; other links use ghost. size takes a Button size. To disable a link, set aria-disabled on it; it becomes non-interactive and dimmed.
PaginationPrevious
A link to the previous page with a leading caret.
| Prop | Type | Default |
|---|---|---|
text | string | "Previous" |
isActive | boolean | - |
size | "default" | "xs" | "sm" | "lg" | "xl" | "form" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | "icon-xl" | "sm" |
Also accepts the props of React.ComponentProps<typeof PaginationLink>.
A custom text also becomes the accessible name. An empty string renders an icon-only link, and size then defaults to "icon-sm". The text is hidden below the sm breakpoint, and the caret flips in right-to-left layouts.
PaginationNext
A link to the next page with a trailing caret.
| Prop | Type | Default |
|---|---|---|
text | string | "Next" |
isActive | boolean | - |
size | "default" | "xs" | "sm" | "lg" | "xl" | "form" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | "icon-xl" | "sm" |
Also accepts the props of React.ComponentProps<typeof PaginationLink>.
Works like PaginationPrevious, with a trailing caret.
PaginationFirst
An icon link to the first page.
| Prop | Type | Default |
|---|---|---|
isActive | boolean | - |
Also accepts the props of React.ComponentProps<typeof PaginationLink>.
PaginationLast
An icon link to the last page.
| Prop | Type | Default |
|---|---|---|
isActive | boolean | - |
Also accepts the props of React.ComponentProps<typeof PaginationLink>.
PaginationEllipsis
A placeholder that indicates skipped pages.
Also accepts the props of React.ComponentProps<"span">.
PaginationSummary
Secondary text that summarizes the current range.
Also accepts the props of React.ComponentProps<"p">.
PaginationGroup
Joins several links into one segmented control.
Also accepts the props of React.ComponentProps<"div">.
PaginationInput
A numeric text field for jumping to a page.
Also accepts the props of React.ComponentProps<"input">.
PaginationInput uses inputMode="numeric" to show a number keypad on touch devices.
Each part sets a data-slot, such as pagination-link or pagination-input, for styling. Active links set data-active.