Part of the jedee wiki — An LLM wiki written by an AI, Claude Code, based on the methods and techniques used by this site.

The main menu

On GitHub: , updated

A site menu that collapses behind a button is one of the few interface patterns that genuinely needs JavaScript, which makes it a standing test of whether a site’s enhancement layers are real. The robust arrangement, set out in Manuel Matuzović’s Building the main navigation for a website, is to build the list first and add the button last: plain <a> elements, wrapped in <ul role="list">, inside a labeled <nav> landmark, with the toggle injected by script from a <template>. Nothing hides the list except a button that, by construction, only exists when the script that operates it has run.

Which leaves the question of how CSS knows. There are two mechanisms and they answer different questions.

@media (scripting: none) asks whether the browser can run scripts. It is the only option when the rule has to apply before any script has run — hiding a panel that would otherwise flash open on load.

A structural selector asks whether this particular script actually did its work:

.thing:not(:has(.injected-control)) { /* the fallback layout */ }

That covers more ground: JavaScript disabled, blocked by an extension, failed on the network, or loaded and threw. It is also testable — delete the injected element in DevTools and the fallback appears — where scripting: none can only be exercised by turning JavaScript off for real.

The fallback that a hidden menu falls back to should not be the hidden layout with the hiding removed. A panel designed as a dropdown is sized, positioned and columned for a dropdown; dropped into normal flow it can be worse than useless while remaining, technically, visible.

In jedee

One disclosure: a MENU ⌄ button drops a two-column, table-of-contents-style panel of every post type — icon, name, leader dots, count. It replaced a burger drawer. The markup is partials/main-nav.njk; the button lives in a <template id="menu-template"> and is cloned by scripts/bundle/nav-menu.js, which inserts it before the list so tab order matches visual order. Site search's panel anchors to the same header row, so each trigger closes the other.

A browser window at 1280 pixels. In the header, a breadcrumb trail on the left and a MENU button on the right; below the button, an open panel listing sixteen post types in two columns, each row an icon, a name, a row of leader dots and a count.A browser window at 1280 pixels. In the header, a breadcrumb trail on the left and a MENU button on the right; below the button, an open panel listing sixteen post types in two columns, each row an icon, a name, a row of leader dots and a count.
The disclosure open, with JavaScript, at 1280px. Each row is icon, name, leader dots, count; the trigger fills with the panel's surface so the two read as one sheet.

Diverges from Eleventy Excellent, whose nav is a horizontal link list with an optional drawer.

The critical-path file css/local/nav-menu-cls.css is the one place scripting is used, and it is used inverted:

@media (scripting: enabled) {
  .mainnav > ul { display: none; }
}

Everything else keys off the button’s absence, so it also holds if the script fails.

The panel’s width

The open panel is absolutely positioned under the button, so nothing in the page gives it a width; it has to be told one. It gets a cap and nothing else:

.menu-toggle + .megamenu {
  --megamenu-width: min(40rem, 100%);
  inset-inline-end: 0;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}

The columns are Every Layout’s Grid: as many 15rem tracks as fit, stretched to share the rest. That gives two columns from a window of about 600px and one below it, without a breakpoint. The cap is the only fixed number, and it has to leave room for the tracks. At min(30rem, 100%) two 15rem tracks plus the --space-l gap and the panel’s padding never fit, and the menu was one long column at every width.

For one day the width came from the dev grid instead: five columns wide, snapped to the nearest column line. The grid’s unit was derived from 100vw, which counts a scrollbar the header row does not, and with an always-visible scrollbar the panel landed a column off, past the left edge of the window on narrow screens. That is written up on Viewport units. The search panel shares the header row and the same rule, at 30rem.

The no-JS layout

Without the button the panel keeps its <ul> but becomes a row of wrapping pills in normal flow, on a line of its own under the breadcrumb and left-aligned with it — two rows at 1280px, seven at 375px. Each count is in parentheses, Articles (2), drawn by ::before and ::after on .megamenu-count: without the leader dots a bare number runs into the next pill’s label. Until 2026-11-13 the pills were right-aligned beside the breadcrumb on a wide screen, which left them starting at a different point on every row. The leader dots are dropped (an empty flexible spacer only reads as a leader when every row shares a width) and the padding tightens.

Two browser windows side by side, both without JavaScript. In both, the post-type links sit under the breadcrumb, left-aligned with it: two lines of pills at 1280 pixels, seven at 375 pixels, each count in parentheses.Two browser windows side by side, both without JavaScript. In both, the post-type links sit under the breadcrumb, left-aligned with it: two lines of pills at 1280 pixels, seven at 375 pixels, each count in parentheses.
Without JavaScript at 1280px (left, two rows) and 375px (right, seven): plain pills under the breadcrumb, with no leader dots.

Before that, the panel kept its dropdown layout: two columns of minmax(15rem, 1fr) inside a header row with nowhere near 30rem to give, so auto-fit collapsed to one column and the header became a sixteen-row list that pushed the page content most of a screen down.

The flexbox trap next to it

The header row is a .repel holding the breadcrumb and a cluster with the nav and theme toggle. breadcrumb.css pins that cluster with flex: none, because with JavaScript on it holds only a small button and a moon. Relaxing that pin to flex: 1 1 auto for the fallback truncated the breadcrumb to a letter and an ellipsis.

Flexbox distributes shrinkage in proportion to base size. With flex-basis: auto the pill row’s base is its max-content — roughly 2000px — against the trail’s ~200px, so the deficit was split in that ratio and the breadcrumb surrendered nearly half its width despite having none to spare.

.site-header .repel:has(.mainnav):not(:has(.menu-toggle)) {
  --repel-wrap: wrap;
}

.site-header .repel > .cluster:has(.mainnav):not(:has(.menu-toggle)) {
  --cluster-wrap: nowrap;
  flex: 1 1 100%;
  min-inline-size: 0;
}

A basis of 100% sends the pill row to a line of its own at every width, so it never competes with the trail for space. Until 13 November 2026 the basis was 22rem, which let the row grow into what the trail left on a wide screen and wrap onto its own line only on a narrow one. The trail’s truncation is the -webkit-line-clamp described in Text wrapping.

Two browser windows stacked, identical except for the header row's flex declarations. In the upper one the breadcrumb reads Photos then a single truncated letter; in the lower one it reads Photos then Pier 4, Ribersborg in full, with the pills on a line of their own below it.Two browser windows stacked, identical except for the header row's flex declarations. In the upper one the breadcrumb reads Photos then a single truncated letter; in the lower one it reads Photos then Pier 4, Ribersborg in full, with the pills on a line of their own below it.
Both 1280px, no JavaScript. Above, the cluster relaxed to flex: 1 1 auto crushes the breadcrumb; below, as shipped.

The two wrap values go through the compositions’ custom properties rather than declaring flex-wrap from outside; flex and min-inline-size stay plain declarations because they size the element as an item of the row, not the cluster’s internals. That distinction, and the two traps in converting a declaration to a knob, are in Configuring a layout composition — which is also where the no-JS pill row’s .cluster class comes from, since this page’s fallback row used to rebuild that composition by hand.

The :has(.mainnav) guard is load-bearing: during the soft launch the header omits the nav entirely in production, which also means no button, and without it the cluster would take a whole line around nothing but the theme toggle.

Contrast is a property of the pairing, not the color

The count numbers are color-mix(in oklab, var(--color-text) 80%, var(--color-bg)), calibrated against the panel’s lifted surface. The pills sit on the plain page background, where that same mix measures 4.43:1 in light mode. The fallback overrides it to 88% — 5.29:1 light, 8.52:1 dark. No color value changed; the surface under it did, and that was enough to fail AA.

Since 2026-11-17 the labels rest in the same muted mix as the counts (--megamenu-row-color: var(--megamenu-count-rest)), so the fallback’s 88% covers them too. On the panel they measure 4.63:1 in light and 5.05:1 in dark. Hover, keyboard focus and the current section raise label and count to --color-text. The icons then needed a fixed rest color of their own (Icons).

Accessibility details worth copying

  • The panel closes with visibility: hidden, never opacity or transform alone, so its links are not tab-focusable while closed.
  • The open/closed state lives on the button’s aria-expanded; the CSS selects [aria-expanded='true'] + .megamenu rather than toggling a class on the list.
  • role="list" stays on the <ul> after list-style: none, which WebKit otherwise takes as license to drop list semantics.
  • A focused row gets position: relative; z-index: 1 so its offset ring is not clipped by the next row’s background — the same failure mode as Focus rings and paint containment.
  • The reveal transition is inside @media (prefers-reduced-motion: no-preference), the same opt-in-to-motion idiom as The theme toggle.

Raw source: src/_raw/dev-notes/How the main menu degrades without JavaScript.md

Keyboard shortcuts

⌘K
Open the search
↓ ↑
Move through the search results
Enter
Open the selected result
Esc
Close the search or this list
⌥G
Show or hide the layout grid
⌥R
Show or hide the rhythm lines
⌥L
Open this list