A wider screen, please

This page features interactive demos and side-by-side code samples that need at least 340 pixels of horizontal space. Please widen your browser window, or rotate your device, to continue.

Morpheus v0.1.0
v0.1.0

Pagination#

Component <neo-pagination> is adaptive page navigation. Set page and pages attributes and the host builds the Prev / boundary / window / boundary / Next chips, flags the current page with aria-current="page", and dispatches neo-pagination-change on click. A ResizeObserver shrinks the sibling window first, then the boundary count, until the chips fit on a single row.

Default
Sibling count = 2
Boundary count = 2
First page
Last page
Short run
Custom prev / next slots
No prev / next buttons
Disabled
Deactivate Rename Duplicate
Delete
New state Toggle autoplay
HTML CSS

The selected state's markup and its scoped CSS. The CSS is wrapped in <style>@scope { ... }</style> and applies to the preview only. Edits change the preview above, applied live while Sync is on, or when you click Patch or Replace. Patch morphs the preview; Replace swaps it outright.

Replace Patch

Signals

Datastar signals declared in the selected state's markup. Change a value to drive the preview, applied live while Sync is on, or when you click Patch.

Patch

Reference#

Attributes #

NameTypeDefaultDescription
pagenumber reflected observed1Active page (1-indexed). Two-way bind via data-attr:page data-on:neo-pagination-change.
pagesnumber observed1Total page count. page is clamped to [1, pages] on every render.
sibling-countnumber observed1Pages shown on each side of the active one. Increase to make ±N navigation cheaper; the adapt loop shrinks this first when the row runs out of room.
boundary-countnumber observed1Pages pinned at the start and end of the run. The adapt loop shrinks it after the sibling window has bottomed out at 0.
disabledboolean observedfalseGreys every chip and ignores clicks. Useful while a parent dataset is still loading.
aria-labelstring"Pagination"Set on the host's role="navigation" so screen readers announce the landmark.

Slots #

NameDescription
template[data-neo-pagination-prev]Inner HTML of the prev button. Captured once on connect from a <template> child; the kit re-uses it on every render. Default (no template) is a single chevron-left icon (icon-only button). An empty template (<template data-neo-pagination-prev></template>) opts out of the prev button entirely.
template[data-neo-pagination-next]Same as the prev slot, on the right; default is chevron-right, empty opts out.

Events #

NameDetailBubblesDescription
neo-pagination-change{ page: number }yesFires when the user picks a chip or clicks prev / next. page is the new active page; the host has already reflected page= by the time the event dispatches.

CSS variables #

NameDefaultDescription
--neo-pagination-gapcalc(var(--page-spacing, 0.25rem) * 1)Gap between chips.
--neo-pagination-page-min2.25remMinimum width and height of a page chip.
--neo-pagination-active-bgvar(--accent, currentColor)Background of the active page chip.
--neo-pagination-active-colorvar(--accent-fg, var(--page-bg, #fff))Text color of the active page chip.
--neo-pagination-active-hover-bgcolor-mix(in srgb, var(--neo-pagination-active-bg), #000 12%)Active chip background on hover.
--neo-pagination-active-active-bgcolor-mix(in srgb, var(--neo-pagination-active-hover-bg), #000 8%)Active chip background while pressed.

Examples#

Sibling count = 2#

sibling-count="2" reveals two neighbours on each side of the active page rather than one. Useful when users frequently jump ±2 pages and a single neighbour reads as too tight.

Boundary count = 2#

With boundary-count="2" the first and last two pages always render, handy for tables where users habitually jump to "page 1 / 2" or "second-to-last / last".

First page#

When the current page sits at or near the boundary, the matching ellipsis collapses and the window snaps flush against the edge run.

Last page#

Short run#

With fewer pages than the configured window plus boundary, the host lays out every page with no ellipses.

Custom prev / next slots#

The host exposes two <template> slots, [data-neo-pagination-prev] and [data-neo-pagination-next], whose inner HTML becomes the body of the prev / next buttons. Default content is a single chevron icon, so a bare host renders as icon-only.

No prev / next buttons#

Pass a <template data-neo-pagination-prev> / <template data-neo-pagination-next> with no children and the matching button is omitted entirely: pure page chips, no prev / next rail. Useful when the dataset's prev / next is wired elsewhere (keyboard shortcut, sidebar nav).

Disabled#

disabled greys every chip and ignores clicks. Use it while a parent dataset is loading.

Settings

Theme

Default Sunshine Ocean Matrix Rose

Accessibility

Playgrounds

Server Simulator