Skip to content

HyPagination

Usage examples on this page are written for Lit / plain HTML (<hy-pagination>). The same component ships as HyPagination in @whitespaceux/harmony-react (native React 19), with typed wrappers for Angular, Solid, Svelte, and Vue. The API reference below applies to all frameworks.

A navigation control for paging through a large, segmented data set (table rows, search results, a list). Renders numbered page buttons with ellipsis truncation, prev/next (and optional first/last) arrows, an optional rows-per-page selector, and an optional range label.

Controlled by design. The consumer owns pageIndex / pageSize; the component renders that state, emits a single change event on interaction, and the consumer echoes the new state back (slice locally or refetch). This matches hy-table (stateless/controlled) and is the correct model when paired with a state-owning data engine — there is no internal source of truth to drift.

Accessibility: a <nav> landmark with aria-label; the current page button carries aria-current="page"; arrows are disabled at the bounds.

Responsive. A ResizeObserver measures the control's own width and fits the page window to it (the AG Grid / Ant responsive model): siblingCount shrinks as the container narrows, and when even a zero-sibling window no longer fits, the layout collapses to the compact "Page X of Y" form automatically. siblingCount and compact are therefore an upper bound and a forced floor — the rendered window is never wider than the author asks, and compact (when set) pins the compact layout at every width. Until first measured (SSR, first paint) the author's full window renders.

Examples

Basic (controlled)

html
<hy-pagination total="100" page-index="0" page-size="10"></hy-pagination>

With size selector and range label

html
<hy-pagination total="248" page-index="2" page-size="20" show-page-size show-total></hy-pagination>

Forced compact (pins "Page X of Y" at every width)

html
<hy-pagination total="100" page-index="0" page-size="10" compact></hy-pagination>

API

Properties

PropertyAttributeTypeDefaultDescription
totaltotalnumber0Total number of items across all pages.
pageIndexpage-indexnumber0Current 0-indexed page.
pageSizepage-sizenumber10Items per page.
pageSizeOptionsnumber[][10, 20, 50, 100]Options offered by the rows-per-page selector.
siblingCountsibling-countnumber1Maximum page buttons shown on each side of the current page (auto-reduced to fit the container width).
boundaryCountboundary-countnumber1Page buttons pinned at each edge.
showEdgesshow-edgesbooleanfalseRender First / Last jump arrows.
showPageSizeshow-page-sizebooleanfalseRender the rows-per-page selector.
showTotalshow-totalbooleanfalseRender the "1–10 of 100" range label.
compactcompactbooleanfalseForce the compact "Page X of Y" + arrows layout at all widths (narrow containers collapse to it automatically even when unset).
sizesize'small' | 'medium' | 'large''medium'Size variant, propagated to inner controls.
disableddisabledbooleanfalseDisable the whole control.
labellabelstring'Pagination'Accessible label for the navigation landmark.
pageCountnumberTotal page count (>= 1).

Events

EventDetailDescription
changeFired on any page or size change. Detail: PaginationChangeDetail ({ pageIndex, pageSize, reason }). When the size changes, pageIndex resets to 0.

Slots

SlotDescription
infoCustom range/total content, replacing the built-in show-total label.

CSS Parts

PartDescription
baseThe nav landmark element.
listThe page-button row (ul).
pageA page-number button.
page-currentThe current page button (also carries aria-current).
prevThe previous-page arrow button.
nextThe next-page arrow button.
firstThe first-page arrow button.
lastThe last-page arrow button.
ellipsisA collapsed-gap ellipsis.
infoThe range/total label container.
size-selectThe rows-per-page select.

CSS Custom Properties

PropertyDescription
--hy-pagination-gapGap between controls.
--hy-pagination-button-sizeSquare size of page / arrow buttons.
--hy-pagination-radiusCorner radius of the buttons.

Built with Lit. Documented with VitePress.