Detent web components
By Shane Logsdon

Navigation

Page Nav

Implemented

Previous and next document links with direction and titles

detent-page-nav

Port status
Catalog status
implemented
Origin
native-only
Phase
6
Wave
native-only
Group
Navigation

3.5 KB gzip for the class module

Variants

Previous: Docs Next: GitHub

Example labels only. The primary above the Variants heading renders both directions from property-only PageLink data, the first row here hides the empty direction, and the second uses real slotted anchors that win over the data and stay in the light DOM. There is no event: the links are native anchors.

Recorded states

  • hover recorded state; no setter
  • focus-visible recorded state; no setter
  • empty recorded state; no setter

Usage

Import

import '/components/page-nav/define.js';

// or register it yourself
import { DetentPageNav } from '/components/page-nav/page-nav.js';

Attributes

  • label

Properties

  • label
  • previous
  • next

Slots

  • previous
  • next

Events

No events are recorded for this component.

Example

Runnable example: site/examples/page-nav.ts. The snippet below is generated from the catalogued attributes.

<detent-page-nav
  label="Page navigation"
></detent-page-nav>

Property-only values

const element = document.querySelector('detent-page-nav');
if (element !== null) {
  // previous: PageLink | null
  element.previous = undefined;
  // next: PageLink | null
  element.next = undefined;
}

Source

Native-only row: there is no upstream source. The native module lives at:

  • src/components/page-nav/page-nav.ts

Native files

The native module and its artifacts:

  • src/components/page-nav/page-nav.ts
  • src/components/page-nav/styles.css
  • src/components/page-nav/define.ts
  • docs/components/page-nav.md
  • site/examples/page-nav.ts
  • tests/browser/page-nav.spec.ts
  • evidence/components/page-nav.md

API

Boolean attributes follow HTML presence semantics: present means true, absent means false, and disabled="false" still means disabled.

Attributes

Attributes
AttributePropertyTypeDefaultNotes
labellabelstring'Page navigation'Kebab-case attribute; camelCase property.

Properties

Properties
PropertyTypeDefaultNotes
labelstring'Page navigation'Property-only: assign from script; not accepted as an attribute.
previousPageLink | nullnullProperty-only: assign from script; not accepted as an attribute.
nextPageLink | nullnullProperty-only: assign from script; not accepted as an attribute.

Events

No custom events are recorded for this component.

Slots

Slots
SlotNotes
previousConsumer content; rendered through a slot, never re-created.
nextConsumer content; rendered through a slot, never re-created.

CSS customisation

  • Native-only row: no upstream source file, no upstream route (docs/migration/native-only.md).
  • Previous/next document navigation; upstream has only numbered pagination.
  • Data is a plain object per direction, so the site can also slot real anchors for the no-JS path.
  • href is validated against the platform URL allow-list (http/https/mailto/tel/relative/#fragment/protocol-relative); javascript:, data:, vbscript: and file: are refused into an inert anchor with data-refused="true" and one warning (R-3.1).
  • Both directions empty collapses the nav (hidden) and sets data-empty="true" instead of rendering an empty landmark.
  • URL validation is local to the component; when a second component needs it, it moves verbatim to src/lib/url-policy.ts (R-3.3). PageLink.label is the visible page label rendered in part="title"; an optional title becomes the anchor title attribute.

What it does

Rationale. Previous/next page links with a visible direction and page label, reusable by docs, wizards and steppers.

Upstream behaviour
  • Renders previous and next links from plain data
  • A slotted link wins over data and keeps its own semantics and focus
  • Direction and page title are visible text
  • Hides an empty direction and collapses when both are empty
  • Native anchors only: no synthetic navigation and no event
  • Static slotted content stays readable without JavaScript
Differences from upstream
  • Native-only row: no upstream source file, no upstream route (docs/migration/native-only.md).
  • Previous/next document navigation; upstream has only numbered pagination.
  • Data is a plain object per direction, so the site can also slot real anchors for the no-JS path.
  • href is validated against the platform URL allow-list (http/https/mailto/tel/relative/#fragment/protocol-relative); javascript:, data:, vbscript: and file: are refused into an inert anchor with data-refused="true" and one warning (R-3.1).
  • Both directions empty collapses the nav (hidden) and sets data-empty="true" instead of rendering an empty landmark.
  • URL validation is local to the component; when a second component needs it, it moves verbatim to src/lib/url-policy.ts (R-3.3). PageLink.label is the visible page label rendered in part="title"; an optional title becomes the anchor title attribute.
Previous: Docs TOC Next: Content Card

Docs

Components

Project