Skip to content

Pagination

A navigation landmark of page controls: previous and next, boundary and sibling windows with ellipsis truncation, and button or real-link modes.

Import

import { Pagination } from "@hyzer-labs/ui"

Demo

In button mode, page is bindable and onchange fires on every move. The previous and next controls disable natively at the ends, and clicking the current page does nothing.

let page = $state(1);

<Pagination count={10} bind:page />

Props

NameTypeDefaultNote
countnumberRequired. Total pages.
pagenumber1Bindable. 1-based.
siblingsnumber1Pages shown on each side of the current page.
boundariesnumber1Pages pinned at each end.
href(page: number) => stringLink mode: items render as real anchors; omit for button mode.
onchange(page: number) => void
ariaLabelstring'Pagination'Names the landmark.
prevLabelstring'Previous page'
nextLabelstring'Next page'
pageLabel(page: number) => string`Page ${page}`Accessible name per page item.
classstringMerged after the hz-pagination class.

Theme hooks

What this component promises your CSS. The reference theme styles exactly these — from @layer hz-theme, so your unlayered rules win. See Styling Components for the how.

Root class: .hz-pagination

Part classes

HookValuesStyles
.hz-pagination-listchild elementThe row of page controls.
.hz-pagination-pageon a ButtonRides through Button’s class prop, so it lands on a .hz-button — target it accordingly. Tabular numerals and a min-width keep the row from jittering.
.hz-pagination-prevon a ButtonPrevious control. Also a .hz-button.
.hz-pagination-nexton a ButtonNext control. Also a .hz-button.
.hz-pagination-ellipsischild elementThe aria-hidden gap marker.

Accessibility

Pagination renders a <nav> landmark named by ariaLabel. Give it a distinct name when a page hosts several.

Every control is a Button. The current item carries aria-current="page", and page items get full accessible names via pageLabel ("Page 7", not a bare number). Ellipses are decorative.

In link mode, everything is a real <a>. At the ends, the previous and next controls render as disabled Buttons with no href, because a link cannot be disabled and a dead link that announces itself helps no one.

Tab order is native. There are no roving-focus tricks.

References: MDN: <nav>