Pagination
Move through a long list one page at a time with numbered pages or a compact range.
import { Pagination } from '@uthereal/ui/pagination'Pagination playground
Overview
Pagination provides previous and next controls around numbered page buttons or a compact item range (1–10 of 240), plus an optional native page-size selector. The default fixed window shows five pages around the current page and slides as the user navigates. Setting pageWindow="ellipsis" keeps the first and last pages visible with siblingCount neighbors and ellipses between them.
Use Pagination below tables and result lists loaded one page at a time. Show short lists in full without paging, and use incremental loading for infinite feeds.
Usage
'use client'
import { useState } from 'react'
import { Pagination } from '@uthereal/ui/pagination'
export function ResultsPager({ total }: { total: number }) {
const [page, setPage] = useState(1)
return (
<Pagination
count={total}
page={page}
onPageChange={setPage}
pageSizes={[10, 25, 50]}
/>
)
}Pass the total item count to count. Page count derives automatically from count and the active page size, and your application loads the slice for page.
Examples
Compact layout
The playground above shows the default numbered pages layout. Set layout="compact" to show the current item range (rangeLabel, default {start}–{end} of {count}) for narrow toolbars and table footers. Numbers format in the application locale.
Page window
fixed always shows up to five consecutive page buttons. ellipsis anchors the first and last pages and shows siblingCount (0 to 3) buttons beside the current page.
Page size selector
pageSizes renders a styled native <select> labeled by pageSizeLabel. The array must contain unique integers and include defaultPageSize. Changing page size adjusts the current page so the first item of the previous page stays in view.
Controlled state and sizing
Omit page to manage the current page internally from defaultPage, or pass page with onPageChange to control it. Omit pageSize to manage items per page from defaultPageSize, or pass pageSize with onPageSizeChange. Both callbacks fire in controlled and uncontrolled modes. When count shrinks below the current page, Pagination clamps to the last valid page and calls onPageChange.
Button sizes sm, md, and lg render at 32px, 36px, and 44px with 12px numerals.
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
label | stringDefault: "Pagination" | Accessible name of the navigation landmark. Not shown. |
countRequired | integer— | Total number of items across all pages. The number of pages follows from it and the page size. |
defaultPageSize | integerDefault: 10 | Items per page on first render. Later edits do not reset an existing instance. |
defaultPage | integerDefault: 1 | Page shown on first render, from 1. Later edits do not reset an existing instance. |
pageWindow | fixed | ellipsisDefault: "fixed" | fixed (default, Arc) shows five pages around the current one and slides them; ellipsis keeps the first and last pages with ellipses between. |
siblingCount | integerDefault: 1 | With pageWindow ellipsis: page numbers shown on each side of the current page before an ellipsis. |
layout | pages | compactDefault: "pages" | pages shows numbered page buttons; compact shows the range ("1–10 of 240") with previous and next buttons. |
pageSizes | integer[]— | Choices for items per page, e.g. [10, 25, 50, 100]. They must include defaultPageSize. Omit them to hide the selector. |
previousLabel | stringDefault: "Previous page" | Accessible name of the previous button. |
nextLabel | stringDefault: "Next page" | Accessible name of the next button. |
tooltip | booleanDefault: true | Show previousLabel and nextLabel in tooltips on the arrow buttons on hover and keyboard focus. Not shown on a disabled arrow. |
tooltipPlacement | PlacementDefault: "top" | Preferred side of the tooltips. Collision detection flips them when there is no room. |
pageLabel | stringDefault: "Page {page}" | Accessible name of each page button; {page} is replaced by the page number, e.g. "Page 3". |
rangeLabel | stringDefault: "{start}–{end} of {count}" | Range text of the compact layout, a polite status: {start}, {end} and {count} are filled, e.g. "1–10 of 240". |
pageSizeLabel | stringDefault: "Per page" | Visible label of the page size selector. |
size | sm | md | lgDefault: "md" | Button size: 32, 36, or 44 pixels, a step below the control of that size, with 12px numbers. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes use the same interaction behavior. |
theme | PaginationTheme— | Color mode, accent, and semantic tokens. See Theming for all keys and defaults. |
motion | none | subtle | expressiveDefault: "subtle" | Press animation preset. System reduced-motion preferences take precedence. |
motionOptions | PaginationMotionOptions— | Press scale of the arrow buttons. |
dir | ltr | rtl— | Reading direction; pages run from the right and arrows mirror in RTL. Omit it to inherit the page direction. |
The module also exports pageCount, reconcilePage, and reconcilePageSize helpers alongside PaginationIconSlot ('previous' | 'next').
React integration
| Prop | Purpose |
|---|---|
page, onPageChange | Control the 1-based current page. onPageChange fires in both modes. |
pageSize, onPageSizeChange | Control items per page. onPageSizeChange fires in both modes. |
renderIcon(name, context) | Render custom decorative icons for the previous and next arrow buttons. |
preset | Application defaults, overridden by explicit instance arguments. |
tokens | CSS variables applied after the typed theme. |
ref, className, style | Applied to the root <nav> element, which carries the theme tokens. |
| Native attributes | id, aria-*, data-*, and remaining <nav> props forwarded to the root. |
Keyboard & accessibility
| Key | Interaction |
|---|---|
Tab | Move focus through the page-size <select>, arrows, and page buttons. |
Enter, Space | Activate a page or arrow button, or open the native page-size <select>. |
ArrowUp, ArrowDown | Change the focused option in the native page-size <select>. |
Pagination renders a <nav> landmark named by label. Page buttons are named from pageLabel (Page {page}), and the active page exposes aria-current="page" with a raised surface mark so selection never depends on color alone. Previous and next arrows disable at the boundaries and show previousLabel and nextLabel in a tooltip on hover or keyboard focus when tooltip is true. In compact layout, the range renders as role="status" so range updates announce politely. In RTL, page order and arrow icons mirror automatically. Under forced-colors, the active page uses system highlight colors.
Motion and theming
The active-page indicator glides to the selected button on the morph spring, and shifting the fixed window slides page slots on the smooth spring. Arrow buttons press to motionOptions.pressScale (0.96 default) over 100ms ease-out and release on a spring; disabled arrows fade to 0.4 opacity. motion="none" and prefers-reduced-motion: reduce make all updates immediate.
theme accepts a mode, an accent, core and control token groups (controlHeight, controlPaddingX, controlGap, iconSize), and shadowResting. An application-wide UtherealProvider supplies defaults.
Composition
In an agent composition, Pagination is a leaf. The host stores current state at /components/instance-<id>/page and /components/instance-<id>/pageSize, seeded from defaultPage and defaultPageSize. Edits preserve stored values; a stored page size removed from pageSizes falls back to defaultPageSize. See Building with agents.
{
"type": "Pagination",
"props": {
"count": 243,
"layout": "compact",
"pageSizes": [10, 25, 50]
},
"children": []
}