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

@dojo-ng/nav

v0.2.1

Published

Dojo NG nav web component

Readme

@dojo-ng/nav

<dj-nav> — A navigation landmark that collapses into a button and a panel when there is not enough room.

Part of Dojo NG, a framework-agnostic web component library built on Lit. BSD-3-Clause.

This is the "hamburger menu" or "navicon" pattern. A menu button that stays collapsed on a wide desktop screen is a normal use too, not only a mobile layout. Put the links in the default slot as plain <a> elements.

Install

npm install @dojo-ng/nav

Usage

Import the package to register the custom element, then use the tag.

Plain links in a <nav> landmark. Give it a label for the landmark.

<dj-nav label="Site">
  <a href="/docs">Docs</a>
  <a href="/blog">Blog</a>
  <a href="/pricing">Pricing</a>
  <a href="/about">About</a>
</dj-nav>

When it collapses

  • By default the nav collapses when its container is narrower than 45rem.
  • To change that, set the --dj-nav-collapsed custom property on the element: 1 collapses, 0 expands. Because it is a theme token, not a breakpoint property, it can depend on the container: a nav in a narrow sidebar collapses even on a wide screen.
  • The component checks again when its own size changes. After a change that does not resize it, such as a theme switch or a media query on the viewport, call refresh().
  • Only one arrangement is in the DOM at a time: the plain <nav> when expanded, or the button (and, while open, a panel around the same <nav>) when collapsed.

The panel

  • panel="drawer" (the default) uses <dj-slide-pane>, which opens from the side of the reading direction.
  • panel="dropdown" and panel="overlay" are drawn inside the component itself.
  • dj-nav-toggle fires when the panel opens or closes, and dj-nav-collapse when the arrangement changes.

Accessibility

  • This is a disclosure, not a menu (in APG terms): the links stay plain links in a <nav>, and the button has no aria-haspopup.

Tracking the app's navigation

  • Set track and the links follow @dojo-ng/history, with no click handler to write. A plain left click on a link to a page of the same app (target absent or _self, no download, same origin, under the history base) dispatches dj-navigate and is not followed by the browser. Ctrl-, Cmd- and middle-click keep the browser's link behavior.
  • The link whose path is the current location gets aria-current="page", and the others lose it. The match is exact, so a link to /orders is not current at /orders/7. dj-nav owns aria-current on its links while track is on, and clears it when track goes off.
  • In the collapsed arrangement the panel closes after a tracked click and focus goes to the trigger.
  • It needs @dojo-ng/history installed. Without it, track does nothing and nothing throws.

Not built

  • Toolbar-style overflow, which shows what fits and moves the rest into a menu. That is a separate component.

Need one of these? Make a request on Discord or add an issue (work item) on Heptapod.

Properties

↻ marks an attribute reflected to the DOM; a dash means the property is set in JavaScript only.

| Property | Attribute | Type | Default | |---|---|---|---| | label | label | string | — | | open | open ↻ | boolean | false | | panel | panel ↻ | "drawer" \| "dropdown" \| "overlay" | "drawer" | | triggerLabel | trigger-label | string | — | | collapsed | collapsed ↻ | boolean | false | | track | track | boolean | false |

Slots

  • default slot: The links — plain <a> elements.
  • trigger

CSS parts

  • trigger
  • panel
  • nav

Events

  • dj-nav-collapse: Detail { collapsed }.
  • dj-nav-toggle: Detail { open }.
  • dj-navigate: Detail { path, label }.

Methods

  • show()
  • hide()
  • toggle()
  • refresh(): Delegates to TokenFlagController — the escape hatch for a runtime pin or theme switch that ResizeObserver cannot see (it only sees size changes).

Examples

Permanent hamburger

Pin the token directly for a nav that is always collapsed, on any screen — no JS, no special case in the component: it is the same threshold token an app can set on a single instance.

<dj-nav label="Site" style="--dj-nav-collapsed: 1">
  <a href="/docs">Docs</a>
  <a href="/blog">Blog</a>
</dj-nav>

Moving the threshold

45rem is a default, not a hardcoded number. Override it per instance with your own @container query on an ancestor that establishes container-type — set BOTH branches (the default below your threshold, 0 above it), since setting the token at all replaces the component's own rule entirely rather than adjusting it.

<style>
  #wide-nav { container-type: inline-size; }
  #wide-nav dj-nav { --dj-nav-collapsed: 1; }
  @container (min-width: 30rem) {
    #wide-nav dj-nav { --dj-nav-collapsed: 0; }
  }
</style>
<div id="wide-nav">
  <dj-nav label="Site">
    <a href="/docs">Docs</a>
    <a href="/blog">Blog</a>
  </dj-nav>
</div>

Track the current page

With track, a plain click on a link navigates through history and the current link gets aria-current="page".

<dj-nav label="Site" track>
  <a href="/orders">Orders</a>
  <a href="/settings">Settings</a>
</dj-nav>
<script type="module">
  import { createPubSub } from "@dojo-ng/pubsub";
  import { installHistory } from "@dojo-ng/history";
  import "@dojo-ng/nav";
  installHistory(createPubSub());
</script>

Theming

Styled with Dojo NG --dj-* design tokens and exposes ::part() hooks for targeted overrides.

Localization

Follows the project's WCAG 2.2 AA and localization conventions.

More

Live, interactive examples are at play.dojo-ng.com. For the full API reference, theming, accessibility, and localization guides, see the Dojo NG documentation.