Skip to content

MenuItem

Defined in: components/menu.ts:18

A clickable item in a menu or sidebar nav.

Tip: set href and call Aberdeen’s interceptLinks() once at app startup for SPA-style navigation. When href is set, the item is automatically highlighted as active whenever the current URL matches it (via matchCurrent).

label: Slot

Defined in: components/menu.ts:20

Label text or draw function. Strings are rendered as rich text.


optional icon?: Slot

Defined in: components/menu.ts:22

Leading icon drawn before the label.


optional click?: (e) => void

Defined in: components/menu.ts:24

Click handler.

Event

void


optional href?: string

Defined in: components/menu.ts:35

Render as a link (<a>) pointing here. Pairs naturally with interceptLinks() — the item is highlighted automatically when the URL matches, and scrolled into view if its list had scrolled it out.

Under routed S.main() the link carries data-panel=open: a menu row leads elsewhere in the app, so its target arrives with its own stack of columns rather than on top of whatever panel the menu was drawn in. Pass attrs: "data-panel=push" for a row that should stack instead.


optional key?: string

Defined in: components/menu.ts:55

A keyboard shortcut that activates this item: "mod+k", "f2", a bare "?". The spelling, and which keystrokes are yours to take, are documented on bindKey. In a dropdown or context menu the combination shows at the right end of the row (not on a touch device); a nav row — S.main’s sidebar, menu — keeps its label clean and tells it in its tooltip instead. Either way it reaches screen readers as aria-keyshortcuts, and the ? overview (showKeyHelp) lists it under the item’s label. Activating runs click with the KeyboardEvent and follows href as a fresh navigation to it — the target getting its own panel stack, as a nav item’s does.

The shortcut works with the menu shut — rather the point of one on a dropdown or context menu — for as long as whatever owns the items is drawn: the menu, menuButton or addContextMenu call, or S.main’s nav. (The bare showFloatingMenu binds nothing: its menu exists only while it is up.) A disabled item’s key is not bound.


optional tooltip?: Slot

Defined in: components/menu.ts:61

A tooltip for this item, shown on hover and keyboard focus. A string renders as rich text. In a nav, the item’s key is shown underneath it, behind a subtle separator (see MenuItem.key).


optional match?: string | ((path) => boolean)

Defined in: components/menu.ts:71

Pages this item claims beyond its own href: a string claims that path and everything under it ("/mail" claims /mail/…, not /mailbox), a function is asked with the current path. While a claimed page is current, the item is highlighted and the branches above it stay unfolded — for the detail screens a menu has no row of their own: the /thread/[id] a notification lands on, an icon’s page under the gallery’s row. Claims work from the first paint, so cold deep links are covered too.


optional target?: string

Defined in: components/menu.ts:73

target for the link (_blank, etc.). Only meaningful with href.


optional disabled?: boolean

Defined in: components/menu.ts:75

Disables the item.


optional attrs?: string

Defined in: components/menu.ts:77

Aberdeen attr/style string on the item element.


optional items?: MenuEntry[]

Defined in: components/menu.ts:92

Child entries, which turn the item into a collapsible branch of a tree. Only the branch holding the current page is expanded; navigate to another page in the menu and it folds back up. (Navigating to a page the menu doesn’t hold anywhere leaves every fold as it was: there is no better answer to fold up to.) Clicking a branch selects rather than toggles: it follows the item’s own href, or failing that the first linked leaf below it — which is what expands it. A branch with no link anywhere below it falls back to plain open/close toggling.

Expanding is not selecting: a branch click never counts as picking an item (see onLeafSelect on menu), so on a phone the nav stays up while a section unfolds.