LibraryComponents

NestedMenu

Flyout menus with a pointer safe-area triangle for diagonal navigation.

NestedMenu

Domain: navigation
Package path: packages/ui/src/navigation/nested-menu.tsx
Import: @ziteox/ui or @ziteox/ui/navigation

Vertical menu with flyout submenus. When moving the pointer diagonally from a parent item to its submenu, an invisible triangle keeps the flyout open — the same pattern used by macOS context menus and Amazon-style mega menus.

Preview

NestedMenu

Usage

import { NestedMenu } from "@ziteox/ui";

const items = [
  { label: "New File", shortcut: "⌘N" },
  {
    label: "Move to",
    submenu: [
      { label: "Favorites" },
      { label: "Archive" },
      { label: "Projects" },
    ],
  },
  { label: "Delete", destructive: true },
];

export function FileMenu() {
  return (
    <NestedMenu
      items={items}
      onSelect={(item, path) => console.log(item.label, path)}
    />
  );
}

Props

PropTypeDefaultDescription
itemsNestedMenuItem[]—Menu tree
classNamestring—Appended to root
submenuSide"right" | "left""right"Flyout placement
showSafeAreabooleanfalseDebug overlay — dashed triangle when the locked corridor is active
onSelect(item, path) => void—Leaf item click; path is index trail

NestedMenuItem

FieldTypeDescription
labelstringDisplay text
shortcutstringOptional hint (e.g. ⌘N)
destructivebooleanDestructive styling
submenuNestedMenuItem[]Nested flyout items

Low-level utilities

Geometry helpers are exported for custom menu implementations:

import {
  evaluateSubmenuPointer,
  getPointerSafeTriangle,
  isIntentTowardSubmenu,
  isSubmenuIntentActive,
} from "@ziteox/ui";
ExportPurpose
evaluateSubmenuPointerLock / keep-open / close decision
getPointerSafeTriangleTriangle from locked apex + submenu rect
isIntentTowardSubmenuMenu-aim intent detection
isSubmenuIntentActiveWhether corridor blocks other rows
isInSubmenuApproachCorridorHit-test the gap between menu and flyout
isPointInTriangleHit-test a point
pointInRectViewport rect hit-test

Styling

Scoped classes:

  • ziteox-nested-menu
  • ziteox-nested-menu-panel
  • ziteox-nested-menu-submenu
  • ziteox-nested-menu-item
  • ziteox-nested-menu-safe-area (debug overlay only)

Architecture notes

DecisionRationale
showSafeArea propDocs and local QA only — not for production menus
Window mousemoveTriangle must track pointer outside the menu DOM
No icon libraryChevrons are inline SVG
Leaf-only onSelectParent items with submenus open on hover, not click