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
CLI
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
Manual
- Install the dependencies and add the
cnhelper:
-
Add the pieces it builds on: Button.
-
Copy the source into
components/ui/pagination.tsx:
- Update the import paths to match your project.
Usage
Links render as a elements, so pass href for real routes, or href="#" with an onClick that calls preventDefault() for client-side state. Mark the current page with isActive on PaginationLink. To disable an edge link, set aria-disabled on it; it becomes non-interactive and dimmed.
PaginationLink takes a size from the Button sizes and defaults to icon-sm. Set text="" on PaginationPrevious or PaginationNext for icon-only arrows.
Examples
Compact
A page number input with joined previous and next arrows in a PaginationGroup, clamping typed values to the valid range.
Rows per page
A rows-per-page select, a range summary, and first, previous, next and last arrows.
With ellipsis
A long page range shortened with ellipses on both sides of the current page.
Custom labels
Previous and next links relabelled Newer and Older.
Large links
Page links using the larger icon button size.
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 | Description |
|---|---|---|---|
isActive | boolean | - | Marks the link as the current page with aria-current="page". |
Also accepts the props of PaginationLinkProps.
PaginationPrevious
A link to the previous page with a leading caret.
| Prop | Type | Default | Description |
|---|---|---|---|
text | string | "Previous" | The visible label. A custom value also becomes the accessible name; an empty string renders an icon-only link. |
isActive | boolean | - | Marks the link as the current page with aria-current="page". |
Also accepts the props of React.ComponentProps<typeof PaginationLink>.
PaginationNext
A link to the next page with a trailing caret.
| Prop | Type | Default | Description |
|---|---|---|---|
text | string | "Next" | The visible label. A custom value also becomes the accessible name; an empty string renders an icon-only link. |
isActive | boolean | - | Marks the link as the current page with aria-current="page". |
Also accepts the props of React.ComponentProps<typeof PaginationLink>.
PaginationFirst
An icon link to the first page.
| Prop | Type | Default | Description |
|---|---|---|---|
isActive | boolean | - | Marks the link as the current page with aria-current="page". |
Also accepts the props of React.ComponentProps<typeof PaginationLink>.
PaginationLast
An icon link to the last page.
| Prop | Type | Default | Description |
|---|---|---|---|
isActive | boolean | - | Marks the link as the current page with aria-current="page". |
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">.
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. PaginationEllipsisis hidden from assistive technology.PaginationGrouphasrole="group".PaginationInputhas no built-in label; associate one withhtmlFororaria-label.
Notes
- Styling hooks:
data-slotvaluespagination,pagination-content,pagination-item,pagination-link,pagination-ellipsis,pagination-summary,pagination-groupandpagination-input. Active links exposedata-active. - Active links use the
secondarybutton variant and others useghost. - Previous and next text is hidden below the
smbreakpoint, and the carets flip in right-to-left layouts. PaginationInputusesinputMode="numeric"to show a number keypad on touch devices.