Accessibility · Component reference

Page navigator

A searchable outline with real heading destinations and reliable focus transfer.

Published and reviewed · Starlit’s implementation notes

Try the live example

Research and our take

Our recorded research compared reader preferences and accessibility tools across several projects. For this component, these observations informed Starlit’s approach:

  • Fluid UI Options: Separate adjusters for type, contrast, spacing, links, inputs and table of contents. Our decision: Build small independent panels backed by a shared preference controller.
  • MediaWiki accessibility for reading: Reader choices for typography and appearance, with presentation integrated into the site. Our decision: Adapt a designated content region instead of filtering the entire page.

Starlit wrote the shared controller, scoped content adapters and component modules presented here. The referenced widgets are research sources, not browser dependencies. The component also draws on interface work in EvansWiki and PayCal.

Design reasoning

Give long content a navigable outline based on its authored heading structure.

  1. Start with the person’s task and the barrier they may encounter.
  2. Use on substantial articles and documentation. Start with meaningful headings and stable unique heading IDs.
  3. Keep the ordinary content and action usable before adding enhancement.
  4. Search for a heading, activate it, and verify both scroll position and focus. Try content with no headings and dynamically added sections.

Usage pattern

Use on substantial articles and documentation. Start with meaningful headings and stable unique heading IDs.

Impact and tradeoffs

A searchable outline reduces scanning effort. It cannot compensate for a confusing heading hierarchy.

Accessibility solutions

Transfer focus to the destination so keyboard and screen reader users arrive together. Update the outline when headings change.

Build accessible source content first. Personal preferences supplement semantic HTML, useful names, keyboard access and visible focus.

HTML

A concrete usage example. Host these assets on your own origin if you adapt the pattern. Read the source and credits before reuse.

<link rel="stylesheet" href="/open-ui/accessibility/shared/content.css">
<script type="module"
  src="/open-ui/accessibility/components/contents-navigator/index.js"></script>

<article id="reading" data-sdou-a11y-content data-default-theme="dark">
  <div data-sdou-a11y-prose>
    <h2 id="begin">Begin with a clear purpose</h2>
    <p>Readable text and useful controls belong together.</p>
    <h2 id="details">Consider the details</h2>
    <p>The page should remain usable before any enhancement loads.</p>
  </div>
</article>
<sdou-contents-navigator target="#reading"
  storage-key="example.contents-navigator.v1"></sdou-contents-navigator>

Open the HTML usage source

CSS

This is the component stylesheet used inside its Shadow DOM. The shared ui.css supplies its base controls and content.css adapts the reading region. An empty component stylesheet deliberately inherits the shared UI.

.links-list a {
  font-size: 0.9375rem;
}
.links-list .subitem a {
  border-inline-start: 3px solid var(--sdou-ax-teal);
}

JavaScript

This is the actual component module used by the live example. Imports, the base class and shared preferences are dependencies. Keep the component folder and shared folder in their relative positions.

import { A11yComponent } from "../../shared/base.js?v=sdou20261029";
class ContentsNavigator extends A11yComponent {
  static styles = new URL("./component.css?v=sdou20261029", import.meta.url).href;
  render() {
    this.mount(
      "Find your place.",
      "Search the page outline and move directly to a heading. Focus follows the destination.",
      '<label class="field-label" for="outline-search">Find a section</label><input id="outline-search" type="search" autocomplete="off" placeholder="Search this page"><nav aria-label="Reading area outline"><ul class="links-list" data-outline></ul></nav>',
      { reset: false },
    );
  }
  initialize() {
    this.on(this.q("#outline-search"), "input", () => {
      clearTimeout(this.timer);
      this.timer = setTimeout(() => {
        this.renderOutline();
        this.say(this.items.length + " matching sections.");
      }, 150);
    });
    this.renderOutline();
    this.observer = new MutationObserver(() => {
      clearTimeout(this.mutationTimer);
      this.mutationTimer = setTimeout(() => this.renderOutline(), 120);
    });
    this.observer.observe(this.target, {
      childList: true,
      subtree: true,
      characterData: true,
    });
  }
  renderOutline() {
    const query = this.q("#outline-search").value.trim().toLowerCase();
    this.items = [...this.target.querySelectorAll("h2,h3,h4")].filter(
      (h) =>
        !h.closest("[hidden],[aria-hidden=true]") &&
        h.textContent.trim().toLowerCase().includes(query),
    );
    const list = this.q("[data-outline]");
    list.replaceChildren();
    if (!this.items.length) {
      const li = document.createElement("li");
      li.className = "hint";
      li.textContent = "No matching headings. Try another word.";
      list.append(li);
      return;
    }
    this.items.forEach((heading, i) => {
      if (!heading.id) {
        let id = (this.target.id || "sdou-reading") + "-section-" + i;
        while (document.getElementById(id)) id += "x";
        heading.id = id;
      }
      const li = document.createElement("li"),
        a = document.createElement("a");
      a.href = "#" + encodeURIComponent(heading.id);
      a.textContent = heading.textContent.trim();
      a.dataset.heading = heading.id;
      if (heading.tagName !== "H2") li.className = "subitem";
      a.addEventListener(
        "click",
        (event) => {
          event.preventDefault();
          heading.tabIndex = -1;
          heading.focus({ preventScroll: true });
          heading.scrollIntoView({ behavior: "auto", block: "start" });
          this.qa("[data-heading]").forEach((link) =>
            link === a
              ? link.setAttribute("aria-current", "location")
              : link.removeAttribute("aria-current"),
          );
        },
        { signal: this.abort.signal },
      );
      li.append(a);
      list.append(li);
    });
  }
  cleanup() {
    this.observer?.disconnect();
    clearTimeout(this.timer);
    clearTimeout(this.mutationTimer);
  }
}
customElements.define("sdou-contents-navigator", ContentsNavigator);

PHP integration

In your own application, PHP can render this HTML on the server. Here, the example is escaped text only. The library has no PHP runner or execution endpoint. The browser owns the interaction.

<?php
// Server render trusted structure and escape authored text.
// PHP does not implement or save these browser preferences.
declare(strict_types=1);
$title = 'A readable article';
$paragraph = 'Your authored content goes here.';
$e = static fn (string $value): string =>
    htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
?>
<link rel="stylesheet" href="/open-ui/accessibility/shared/content.css">
<script type="module"
  src="/open-ui/accessibility/components/contents-navigator/index.js"></script>
<article id="reading" data-sdou-a11y-content data-default-theme="dark">
  <div data-sdou-a11y-prose>
    <h2 id="begin"><?= $e($title) ?></h2>
    <p><?= $e($paragraph) ?></p>
  </div>
</article>
<sdou-contents-navigator target="#reading"
  storage-key="example.contents-navigator.v1"></sdou-contents-navigator>

Open the PHP rendering source

API and dependencies

Element
sdou-contents-navigator
target
A selector for the content region. Use a unique ID. Components sharing a target share its controller.
storage-key
A stable key for this project. Use the same key for controls targeting the same region. Preferences stay in browser storage when available.
Content
data-sdou-a11y-content marks the target; data-sdou-a11y-prose identifies reading copy. Use data-default-theme="dark" for a dark initial and reset preference.
Event
sdou:a11y-change is dispatched on the target with preferences, palette and reducedMotion in its detail.
Dependencies
Modern JavaScript modules, custom elements, Shadow DOM and native form controls. Dialog, speech, clipboard and fullscreen support depend on the feature and browser.

Read shared/base.js · Read the preference controller · Read the content adapter · Read the shared control styles

Testing and limitations

Search for a heading, activate it, and verify both scroll position and focus. Try content with no headings and dynamically added sections.

The original library validation records automated rule checks, 320px reflow, enlarged text, text spacing, state persistence and relevant functional checks. Unresolved automated Shadow DOM reference checks are recorded separately from browser dialog checks. These historical results are not a new audit of every integration.

Production review still needs assistive technology, touch, zoom, custom styles and representative content. See our testing scope and known gaps. Report a barrier to Starlit.