diff --git a/docs/5-project/web-ui/design-guide.md b/docs/5-project/web-ui/design-guide.md
index 4221624fe..ee4709fe8 100644
--- a/docs/5-project/web-ui/design-guide.md
+++ b/docs/5-project/web-ui/design-guide.md
@@ -155,6 +155,12 @@ list — this doc won't try to keep a duplicate inventory in sync. A yes/no
option in a form uses `CheckboxField`, which sizes its row like the other
fields, rather than a bare ``.
+The header menus (links, user, settings and alerts) share one popover,
+`HeaderMenu` in `@hive/shared`: it owns the open state, the dismiss rules (a
+press outside or Escape closes it) and the popover look, and each menu supplies
+its button and its rows. A new header menu uses it and doesn't write its own
+popover stylesheet.
+
**Every new `ui/` component gets a demo section on `/components` the
same day it lands** — no building block without a place to see it. One
deliberate exception exists today: `FormField`, the internal label+
diff --git a/frontend/packages/shared/package.json b/frontend/packages/shared/package.json
index c6c4e764a..1a528bdb0 100644
--- a/frontend/packages/shared/package.json
+++ b/frontend/packages/shared/package.json
@@ -42,6 +42,8 @@
"./warn-banner.css": "./src/warn-banner/WarnBanner.css",
"./icon-button.js": "./src/icon-button/IconButton.tsx",
"./icon-button.css": "./src/icon-button/IconButton.css",
+ "./header-menu.js": "./src/header-menu/HeaderMenu.tsx",
+ "./header-menu.css": "./src/header-menu/HeaderMenu.css",
"./tone.js": "./src/tone.ts",
"./badge.js": "./src/badge/Badge.tsx",
"./badge.css": "./src/badge/Badge.css",
diff --git a/frontend/packages/shared/src/header-menu/HeaderMenu.css b/frontend/packages/shared/src/header-menu/HeaderMenu.css
new file mode 100644
index 000000000..c86ad77f1
--- /dev/null
+++ b/frontend/packages/shared/src/header-menu/HeaderMenu.css
@@ -0,0 +1,68 @@
+@import "../icon-button/IconButton.css";
+/* — the one popover every header menu (links, user, settings,
+ alerts) opens. Right-anchored: each trigger sits at the end of a header's
+ icon cluster, so a left anchor would push it off-screen. */
+.header-menu {
+ position: relative;
+ display: inline-block;
+}
+.header-menu-popover {
+ position: absolute;
+ top: calc(100% + 0.4em);
+ right: 0;
+ z-index: var(--z-popover);
+ display: flex;
+ flex-direction: column;
+ min-width: 12em;
+ padding: 0.4em;
+ border: 1px solid var(--border);
+ border-radius: var(--radius-md);
+ background: var(--bg-elev);
+ box-shadow: var(--shadow-pop);
+ animation: header-menu-enter 140ms ease;
+}
+/* A long list, such as the firing alerts: wide, and it scrolls. */
+.header-menu-wide {
+ gap: 0.4em;
+ width: min(26em, calc(100vw - 2em));
+ max-height: 70vh;
+ overflow-y: auto;
+}
+/* Mount-triggered, not a state transition: the popover only exists in the DOM
+ while open, so a keyframe on entry is the right tool. */
+@keyframes header-menu-enter {
+ from {
+ opacity: 0;
+ transform: translateY(-0.25em) scale(0.98);
+ }
+ to {
+ opacity: 1;
+ transform: none;
+ }
+}
+@media (prefers-reduced-motion: reduce) {
+ .header-menu-popover {
+ animation: none;
+ }
+}
+:root[data-motion="reduce"] .header-menu-popover {
+ animation: none;
+}
+:root[data-motion="allow"] .header-menu-popover {
+ animation: header-menu-enter 140ms ease;
+}
+/* A row that is a link or a button. */
+.header-menu-item {
+ display: flex;
+ align-items: center;
+ gap: 0.5em;
+ min-height: 2.75em;
+ padding: 0.4em 0.6em;
+ border-radius: var(--radius-sm);
+ color: var(--fg);
+ text-decoration: none;
+ white-space: nowrap;
+}
+.header-menu-item:hover {
+ background: var(--bg);
+}
diff --git a/frontend/packages/shared/src/header-menu/HeaderMenu.tsx b/frontend/packages/shared/src/header-menu/HeaderMenu.tsx
new file mode 100644
index 000000000..32a8f1533
--- /dev/null
+++ b/frontend/packages/shared/src/header-menu/HeaderMenu.tsx
@@ -0,0 +1,82 @@
+// — a header icon button that opens a popover. The links, user,
+// settings and alerts menus all take this shape, so the open state, the
+// dismiss rules and the popover's look live here once: a menu supplies its
+// trigger and its rows and nothing else.
+//
+// A press outside or Escape closes it, and Escape puts the focus back on the
+// button. `children` is a function of `close` for rows that shut the menu when
+// picked (a link, a log-out), or plain content for rows that stay open.
+//
+// Styles live in `./HeaderMenu.css`, which each menu's own stylesheet
+// `@import`s: the dashboard's JS bundle loads `.css` imports as text, so a
+// component that imported it would not style there.
+import type { ComponentChildren } from "preact";
+import { useRef, useState } from "preact/hooks";
+import { IconButton } from "../icon-button/IconButton.js";
+import { useDismiss } from "../use-dismiss.js";
+
+export interface HeaderMenuProps {
+ /** The button's accessible name; also the popover's, unless `popoverLabel` is set. */
+ label: string;
+ /** What the button shows: an icon, or the avatar's initial. */
+ trigger: ComponentChildren;
+ popoverLabel?: string;
+ /** For the button: the user menu's avatar colour comes through these. */
+ triggerClass?: string;
+ triggerStyle?: Record;
+ /** A class on the root, for a menu's own selectors. */
+ class?: string;
+ /** A class on the popover, such as `header-menu-wide` for a long list. */
+ popoverClass?: string;
+ children: ComponentChildren | ((close: () => void) => ComponentChildren);
+}
+
+export function HeaderMenu({
+ label,
+ trigger,
+ popoverLabel,
+ triggerClass,
+ triggerStyle,
+ class: rootClass,
+ popoverClass,
+ children,
+}: HeaderMenuProps) {
+ const [open, setOpen] = useState(false);
+ const rootRef = useRef(null);
+ const close = () => setOpen(false);
+
+ useDismiss({
+ open,
+ onDismiss: close,
+ inside: [rootRef],
+ focusOnEscape: () => rootRef.current?.querySelector("button") ?? null,
+ });
+
+ return (
+
+ {typeof children === "function" ? children(close) : children}
+
+ ) : null}
+
+ );
+}
diff --git a/frontend/packages/shared/src/jobq-graph/jobq-graph.css b/frontend/packages/shared/src/jobq-graph/jobq-graph.css
index 1cb9d20d1..1d753d554 100644
--- a/frontend/packages/shared/src/jobq-graph/jobq-graph.css
+++ b/frontend/packages/shared/src/jobq-graph/jobq-graph.css
@@ -44,7 +44,7 @@
creates a new `.jg-node` DOM node when its `key` (the node id) is
genuinely new, so this only plays once per node, the first time it
appears in a fetched snapshot. Same shape as Shell.css's
- `shell-page-enter` / the links menu's `links-menu-popover-enter` —
+ `shell-page-enter` / the header menu's `header-menu-enter` —
see either for the three-rule motion-guard this mirrors. */
.jg-node {
margin: 0;
diff --git a/frontend/packages/shared/src/links-menu/LinksMenu.css b/frontend/packages/shared/src/links-menu/LinksMenu.css
index c4989ff09..57b109c11 100644
--- a/frontend/packages/shared/src/links-menu/LinksMenu.css
+++ b/frontend/packages/shared/src/links-menu/LinksMenu.css
@@ -1,63 +1,5 @@
-@import "../icon-button/IconButton.css";
-/* (@hive/shared) — a header icon button (the shared `IconButton`)
- and its popover. No `margin-left: auto` here: the mounting page's header owns
- pushing the action group to the right edge (the swarm UI's
- `.shell-header-actions`, the dashboard's `.dashboard-chrome-actions`). */
-.links-menu {
- position: relative;
-}
-.links-menu-popover {
- position: absolute;
- top: calc(100% + 0.4em);
- right: 0;
- z-index: var(--z-popover);
- display: flex;
- flex-direction: column;
- min-width: 10em;
- padding: 0.4em;
- border: 1px solid var(--border);
- border-radius: var(--radius-md);
- background: var(--bg-elev);
- box-shadow: var(--shadow-pop);
- animation: links-menu-popover-enter 140ms ease;
-}
-/* Mount-triggered, not a state transition — the popover only exists in
- the DOM while open (`{open ?
: null}`), so a keyframe animation
- on entry is the right tool, same shape as `.shell-body`'s own
- `shell-page-enter` (Shell.css) — that's the precedent every popover
- in this issue's "menus should animate" ask follows. */
-@keyframes links-menu-popover-enter {
- from {
- opacity: 0;
- transform: translateY(-0.25em) scale(0.98);
- }
- to {
- opacity: 1;
- transform: none;
- }
-}
-@media (prefers-reduced-motion: reduce) {
- .links-menu-popover {
- animation: none;
- }
-}
-:root[data-motion="reduce"] .links-menu-popover {
- animation: none;
-}
-:root[data-motion="allow"] .links-menu-popover {
- animation: links-menu-popover-enter 140ms ease;
-}
-.links-menu-item {
- display: flex;
- align-items: center;
- gap: 0.5em;
- min-height: 2.75em;
- padding: 0.4em 0.6em;
- border-radius: var(--radius-sm);
- color: var(--fg);
- text-decoration: none;
- white-space: nowrap;
-}
-.links-menu-item:hover {
- background: var(--bg);
-}
+/* (@hive/shared) — a `HeaderMenu` of links; the popover and the
+ link row are `HeaderMenu.css`'s. No `margin-left: auto` here: the mounting
+ page's header owns pushing the action group to the right edge (the swarm
+ UI's `.shell-header-actions`, the dashboard's `.dashboard-chrome-actions`). */
+@import "../header-menu/HeaderMenu.css";
diff --git a/frontend/packages/shared/src/links-menu/LinksMenu.tsx b/frontend/packages/shared/src/links-menu/LinksMenu.tsx
index f4086357b..942dd45e2 100644
--- a/frontend/packages/shared/src/links-menu/LinksMenu.tsx
+++ b/frontend/packages/shared/src/links-menu/LinksMenu.tsx
@@ -10,10 +10,8 @@
// imports or `@import`s itself: the dashboard's JS bundle loads `.css`
// imports as text, so a component that imported it would not style there
// (the same split as `UserMenu`).
-import { useRef, useState } from "preact/hooks";
-import { IconButton } from "../icon-button/IconButton.js";
+import { HeaderMenu } from "../header-menu/HeaderMenu.js";
import { LinkIcon } from "../icons.js";
-import { useDismiss } from "../use-dismiss.js";
import { linkAttrs, type MenuLink } from "./links.js";
export type { MenuLink };
@@ -26,44 +24,24 @@ export function LinksMenu({
/** The button's accessible name. */
label?: string;
}) {
- const [open, setOpen] = useState(false);
- const rootRef = useRef(null);
-
- // A press outside or Escape closes it; Escape puts the focus back on the button.
- useDismiss({
- open,
- onDismiss: () => setOpen(false),
- inside: [rootRef],
- focusOnEscape: () => rootRef.current?.querySelector("button") ?? null,
- });
-
if (links.length === 0) return null;
return (
-