Composite

Pager

A labelled previous / next navigation with the page title on each link.

Previous and next

prevButton and nextButton are Buttons; each renders when set. Its subtitle is the page title, shown under a small “Previous” or “Next”.

both
---
import PagerBlock from '@alfadormx/blocks/composite/Pager.astro';

const prev = { href: '/documentation/composite/NavigationTreeHorizontal' };
const next = { href: '/documentation/composite/PostCard' };
---

<PagerBlock
  prevButton={{ ...prev, subtitle: 'NavigationTreeHorizontal' }}
  nextButton={{ ...next, subtitle: 'PostCard' }}
/>

Next only

A lone next link sits at the inline end: right in left-to-right text, left in right-to-left.

lone-next
---
import PagerBlock from '@alfadormx/blocks/composite/Pager.astro';

const next = { href: '/documentation/composite/PostCard' };
---

<PagerBlock nextButton={{ ...next, subtitle: 'PostCard' }} />

Previous only

A lone previous link sits at the inline start.

lone-prev
---
import PagerBlock from '@alfadormx/blocks/composite/Pager.astro';

const prev = { href: '/documentation/composite/NavigationTreeHorizontal' };
---

<PagerBlock prevButton={{ ...prev, subtitle: 'NavigationTreeHorizontal' }} />

Long titles

The row wraps, and a long title wraps inside its link.

long-titles
---
import PagerBlock from '@alfadormx/blocks/composite/Pager.astro';

const prev = { href: '/documentation/composite/NavigationTreeHorizontal' };
const next = { href: '/documentation/composite/PostCard' };
---

<PagerBlock
  prevButton={{
    ...prev,
    subtitle: 'A horizontal navigation bar with dropdown groups for the main site sections',
  }}
  nextButton={{
    ...next,
    subtitle: 'A blog post card with its cover, date, reading time, excerpt and every tag',
  }}
/>

Custom labels

ariaLabel names the landmark; each link’s label replaces the built-in text. defaultButtonConfig is merged under both links.

custom-labels
---
import PagerBlock from '@alfadormx/blocks/composite/Pager.astro';

const prev = { href: '/documentation/composite/NavigationTreeHorizontal' };
const next = { href: '/documentation/composite/PostCard' };
---

<PagerBlock
  ariaLabel="Documentation pages"
  prevButton={{ ...prev, label: 'Back', subtitle: 'NavigationTreeHorizontal' }}
  nextButton={{ ...next, label: 'Continue', subtitle: 'PostCard' }}
  defaultButtonConfig={{ intent: 'primary' }}
/>

Slot

The default slot renders between the links. Here the row is centred, and class: 'ms-0' on nextButton cancels its inline-end default.

slot
---
import PagerBlock from '@alfadormx/blocks/composite/Pager.astro';

const prev = { href: '/documentation/composite/NavigationTreeHorizontal' };
const next = { href: '/documentation/composite/PostCard' };
---

<PagerBlock class="justify-center" prevButton={{ ...prev }} nextButton={{ ...next, class: 'ms-0' }}>
  <p class="m-0 text-sm text-emphasis">Page 2 of 3</p>
</PagerBlock>

API Reference

PropTypeDefaultDescription
prevButtonButtonProps—Previous link; renders when set (default: outline, left arrow, per-language "Previous"). `subtitle` is the page title, shown as the second line.
nextButtonButtonProps—Next link; renders when set and sits at the inline end (default: outline, right arrow, per-language "Next").
defaultButtonConfigLayerConfig<ButtonProps>—Layer merged under both links, under each link's own values.
ariaLabelstring—Accessible name of the navigation landmark (default: per-language "Pagination").
langCodestring—Language of the built-in labels (default: the site's default language).
gap'none' | 'tight' | 'normal' | 'loose''normal'Space between the links and the slot (default: 'normal').
classstring—Classes on the `<nav>` (`data-pager`).
idstring—`id` on the `<nav>`.