Skip to content

Pagination ​

Data pagination navigation with page-number ellipsis, prev/next flipping, configurable sibling page count, total display, page-size switching and quick jump.

Basic usage ​

Basic usage

Page-number ellipsis ​

Ellipsis for many pages

Sibling page count ​

siblings control

siblings="1" (default)siblings="2"

Page-number cap ​

pager-count page-number cap

siblings="2" (no cap, 7 page buttons)siblings="2" + pager-count="5" (truncation wins, only 5)pager-count="5" (100 pages, only 5 page buttons)

When the cap is exceeded, the window shrinks centered on the current page, leaving at least 2 pages on each side of an ellipsis (first/last pages always reachable); values below the minimum 5 fall back to 5 with a console warning.

Total count ​

show-total displays the total

show-total displays "X items in total"Hidden when not set

Page-size switching ​

page-sizes dropdown

10 per page, currently on page 1

Switching the page size resets to page 1 and fires oas-change with detail: { page: 1, pageSize }.

Page-size switch threshold ​

total-boundary controls the page-size switcher

total-boundary="100": the page-size dropdown is hidden when total ≤ 100 (here total=30, no dropdown)Click the buttons to raise total (>100) so the switcher appears; lower it to hide againtotal 30 → 300total 300 → 30total=30 (switcher hidden)

With total-boundary set, the page-size dropdown renders only when total exceeds the threshold; without it, the current behavior is kept (dropdown shows whenever page-sizes is set).

Quick jump ​

show-jumper jump to a page

Currently on page 3

Enter a page number and press Enter to jump (out-of-range values are clamped to the valid range), firing oas-change with detail: { page, pageSize }.

Combined usage ​

Total + page-size + quick jump

20 per page, currently on page 1

Flip event ​

oas-change event

Currently on page 1

Disabled state ​

disabled disables everything

All page buttons, the page-size dropdown and the jumper input are disabled

Sizes ​

size five tiers (xs / sm / md / lg / xl)

Defaults to md; invalid values fall back to md with a console warning.

Simple mode ​

simple minimal form

simple + show-jumper combined

The simple form renders only the prev/next buttons and a "current / total pages" text; it is mutually exclusive with the page-number ellipsis algorithm (simple wins).

Unknown-total form ​

show-more for unknown totals

When total is unknown (≤0), renders "Previous / More / Next"; More is a non-clickable status indicator, prev/next flip current ± 1Currently on page 1 (no total concept)show-more is ignored when total > 0 (normal page numbers)

show-more targets unknown-total scenarios: no page-number sequence or total text, just the three buttons; show-jumper / page-sizes / hide-on-single do not apply (no page-count concept).

First / last pages ​

show-edges first/last buttons

First page (« disabled)MiddleLast page (» disabled)

Hide on single page ​

hide-on-single hides the component

8 records, 10 per page → single page, component hiddenWithout it, a single page still renders (buttons disabled)

Custom icons ​

prev-icon / next-icon slots

«»

Providing slot="prev-icon" / slot="next-icon" content replaces the default ‹ / › arrows.

Custom total ​

total slot

150 records in total

Providing slot="total" content replaces the built-in "Total N" text; the show-total boolean remains compatible (built-in text shown without slot content).

Flip interception ​

oas-before-change veto

Currently on page 1

oas-before-change fires before a page change/jump with detail: { page }; the host can call preventDefault() to cancel the change (this demo vetoes jumping to page 4). Page-size switching is not intercepted.

Controlled mode ​

controlled current

PreviousNextBack to page 1Currently on page 1

External buttons set the current attribute directly to drive the view (out-of-range values are clamped); the component's own flips fire oas-change and write back the attribute.

Edge cases ​

Single page / first-last disabled

Single-page data (flip buttons disabled)First page (‹ disabled)Last page (› disabled)

href-template renders links

href-template="#page={page}" (native browser navigation; middle/right-click and new-tab work)Currently on page 3target="_blank" passthrough (opens in a new tab)disabled degrades to a non-clickable span

With href-template (containing the {page} placeholder) set, page/prev/next/first/last are rendered as <a href> with {page} replaced by the target page; target is passed through to <a target>. When disabled they degrade to non-clickable spans. Clicking still fires oas-change; vetoing oas-before-change also prevents native navigation.

Responsive ​

responsive switches to minimal on narrow screens

Renders in the simple minimal form when the component is narrower than 640px (ResizeObserver), restores when wide enough; equivalent to explicit simple

Clickable ellipsis ​

ellipsis jumps pages

Currently on page 5

Ellipsis is a clickable button: clicking jumps siblings + 1 pages in that direction (subject to the oas-before-change veto and clamped to the valid range); aria-label via i18n (Jump forward/Jump backward).

Custom page-number content ​

page-item slot template

Slot content holds the {page} placeholder; the component clones it per page

Put template content containing the {page} placeholder; the component clones it into every page-number button and replaces the {page} text with the actual page number (textContent-only replacement, injection-safe). Without the slot, buttons show plain page numbers. prev/next/first/last are unaffected.

API ​

oas-pagination ​

Attributes ​

AttributeDescriptionTypeDefault
currentCurrent page (controlled; flipping updates this attribute)string1
disabledDisables everything: all page buttons with aria-disabled, plus the page-size dropdown and jumper inputboolean—
hide-on-singleHides the whole component when there is a single page (pageCount ≤ 1)boolean—
href-templateLink mode: renders page/prev/next/first/last as <a href> (the {page} placeholder is replaced with the target page); middle/right-click and opening in a new tab work natively; degrades to a non-clickable span when disabledstring—
page-sizeRecords per pagestring10
page-sizesPage-size dropdown options (JSON array), e.g. [10,20,50]; switching resets to page 1string—
pager-countMaximum number of page-number buttons (excluding prev/next/first/last), default 9; when exceeded, the window shrinks centered on the current page (at least 2 pages on each side of an ellipsis, first/last reachable); values below the minimum 5 fall back to 5 with a warningstring9
responsiveResponsive: renders in the simple minimal form automatically when the component is narrower than 640px (ResizeObserver on the host; restores when wide enough); equivalent to explicit simpleboolean—
show-edgesShows first/last double-arrow buttons (« »), disabled at the boundaries; aria-label via i18nboolean—
show-jumperShows a quick-jump input "Jump to page" (Enter to jump, out-of-range clamped)boolean—
show-moreUnknown-total form: when total ≤ 0 renders Previous / More / Next (More is a non-clickable status indicator, styled like a page button but muted; prev/next flip current ± 1 and fire oas-change); ignored when total > 0 (normal page numbers); show-jumper / page-sizes / hide-on-single do not applyboolean—
show-totalShows the total text "Total {total}"boolean—
siblingsNumber of page numbers shown on each side of the current pagestring1
simpleMinimal form: only prev/next buttons and a "current / total pages" text; mutually exclusive with the page-number ellipsis algorithm (simple wins); show-jumper still appliesboolean—
sizeSize tier: xs / small / medium (default) / large / xl; sm/md/lg are accepted aliases; invalid values fall back to medium with a console warningstringmedium
targetPassthrough to <a target> (e.g. _blank) in link mode; only applies when href-template is setstring—
totalTotal number of recordsstring0
total-boundaryPage-size switcher visibility threshold: when set, the page-size dropdown renders only when total exceeds the value (hidden when total ≤ threshold); unset keeps current behavior (dropdown shows whenever page-sizes is set)string—

Events ​

EventDescription
oas-before-changeFires before a page change/jump; preventDefault cancels the change (page-size switching is not intercepted); in link mode it also prevents native navigation
oas-changeFlipping { page }; page-size switch { page: 1, pageSize }; quick jump { page, pageSize }, detail: { page } | { page: 1, pageSize } | { page, pageSize }

Slots ​

NameDescription
next-iconIcon slot for the next button; replaces the default › when present
page-itemCustom page-number content slot: put template content containing the {page} placeholder (e.g. <span slot="page-item" hidden>Page {page}</span>); the component clones it into every page-number button and replaces the placeholder (textContent only, injection-safe); falls back to plain page numbers when absent; prev/next/first/last are unaffected
prev-iconIcon slot for the previous button; replaces the default ‹ when present
totalTotal text slot; replaces the built-in "Total N" text when present

CSS Variables ​

CSS VariableDefault
--oas-pagination-fontvar(--oas-font-size-md)
--oas-pagination-heightvar(--oas-control-height-md)

Page numbers are omitted automatically when out of range, and the first/last flip buttons are disabled at the boundaries.

Released under the MIT OR Apache-2.0 License.