npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

a11y-context-breadcrumb

v1.0.0

Published

Accessible contextual breadcrumb navigation generated from document headings.

Readme

A11y Context Breadcrumb

Accessible contextual breadcrumb navigation generated from document headings. The plugin is framework-agnostic, TypeScript-first, and progressively enhances semantic nav, ol, and li markup.

Installation

npm install a11y-context-breadcrumb
pnpm add a11y-context-breadcrumb
yarn add a11y-context-breadcrumb

Usage

import {
  createA11yContextBreadcrumb
} from "a11y-context-breadcrumb";
import "a11y-context-breadcrumb/styles.css";

const root = document.querySelector("[data-a11y-context-breadcrumb]");

if (root instanceof HTMLElement) {
  createA11yContextBreadcrumb(root);
}

Use initA11yContextBreadcrumbAll() when a page has multiple breadcrumb roots. The package does not auto-initialize on import.

CSS

Import a11y-context-breadcrumb/styles.css for baseline layout, sticky positioning, overflow handling, current-item styling, and visible focus states.

Public custom properties include:

  • --a11y-context-breadcrumb-bg
  • --a11y-context-breadcrumb-color
  • --a11y-context-breadcrumb-muted
  • --a11y-context-breadcrumb-border
  • --a11y-context-breadcrumb-radius
  • --a11y-context-breadcrumb-shadow
  • --a11y-context-breadcrumb-gap
  • --a11y-context-breadcrumb-z
  • --a11y-context-breadcrumb-top
  • --a11y-context-breadcrumb-font-size
  • --a11y-context-breadcrumb-font-size-small

HTML Structure

<nav
  class="a11y-context-breadcrumb"
  aria-label="Current section"
  data-a11y-context-breadcrumb
  data-a11y-context-breadcrumb-content-root="#docs-content"
>
  <ol
    class="a11y-context-breadcrumb__list"
    data-a11y-context-breadcrumb-list
  >
    <li class="a11y-context-breadcrumb__item">
      <span class="a11y-context-breadcrumb__text">Docs</span>
    </li>
  </ol>
</nav>

<main id="docs-content">
  <h2>Forms</h2>
  <h3>Error Summary</h3>
</main>

Headings inside the configured content root become the contextual path. Use data-a11y-context-breadcrumb-label on a heading or section to provide a shorter breadcrumb label, and data-a11y-context-breadcrumb-skip to exclude a subtree.

API

createA11yContextBreadcrumb(root, options) initializes one root and returns an A11yContextBreadcrumb instance.

initA11yContextBreadcrumbAll(options) initializes all [data-a11y-context-breadcrumb] roots in the document.

Instance methods:

  • refresh() re-reads headings and rebuilds the path map.
  • update(reason, force) updates the active breadcrumb path.
  • destroy() removes listeners and plugin-added state.

Key options:

  • contentRoot: selector or element containing headings. Defaults to main.
  • headingSelector: headings to include. Defaults to h2, h3, h4.
  • baseLabel and baseHref: optional leading crumb.
  • baseItems: explicit leading crumbs.
  • maxItems: maximum rendered crumbs before collapsing the middle.
  • sticky, topOffset, and activeOffset: sticky and scroll behavior.
  • generateIds: generate missing heading IDs. Defaults to true.
  • linkItems and linkCurrent: control rendered links.
  • announceChanges: announce the active section in a polite hidden status. Defaults to true.
  • includeHiddenHeadings: include hidden headings when needed.
  • renderItem: customize individual breadcrumb item rendering.
  • onChange: receive active-path changes.

Accessibility Notes

The plugin starts from semantic navigation markup and renders an ordered list of links or text nodes. The current crumb receives aria-current with the configured current value. Breadcrumb links use native anchor keyboard behavior, and default CSS includes a visible :focus-visible style. Active-section changes are mirrored to a visually hidden polite status by default so screen reader users receive concise context updates while scrolling.

When a non-nav root is used, the plugin adds role="navigation" only when no role is already present. Missing heading IDs can be generated for link targets and are removed again by destroy() if the plugin created them.

Examples

Live Demo And GitHub Pages

The repository publishes its static demo and documentation from docs/, while the package artifacts remain in the ignored root dist/ directory.

npm run pages:build

The command builds the package, copies the runtime files that the demo needs into docs/dist/, and generates docs/index.html. Commit the generated docs/ directory with the source changes.

For GitHub Pages, set Settings → Pages → Build and deployment to Deploy from a branch, then choose the main branch and the /docs folder. The published project page is https://vmitsaras.github.io/A11y-Context-Breadcrumb/.

For local package-example work, run npm run build:dist and serve the repository root before opening examples/basic/index.html.

Docs Metadata

import { docs } from "a11y-context-breadcrumb/docs";