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
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
| Prop | Type | Default | Description |
|---|---|---|---|
items | NestedMenuItem[] | — | Menu tree |
className | string | — | Appended to root |
submenuSide | "right" | "left" | "right" | Flyout placement |
showSafeArea | boolean | false | Debug overlay — dashed triangle when the locked corridor is active |
onSelect | (item, path) => void | — | Leaf item click; path is index trail |
NestedMenuItem
| Field | Type | Description |
|---|---|---|
label | string | Display text |
shortcut | string | Optional hint (e.g. ⌘N) |
destructive | boolean | Destructive styling |
submenu | NestedMenuItem[] | Nested flyout items |
Low-level utilities
Geometry helpers are exported for custom menu implementations:
import {
evaluateSubmenuPointer,
getPointerSafeTriangle,
isIntentTowardSubmenu,
isSubmenuIntentActive,
} from "@ziteox/ui";| Export | Purpose |
|---|---|
evaluateSubmenuPointer | Lock / keep-open / close decision |
getPointerSafeTriangle | Triangle from locked apex + submenu rect |
isIntentTowardSubmenu | Menu-aim intent detection |
isSubmenuIntentActive | Whether corridor blocks other rows |
isInSubmenuApproachCorridor | Hit-test the gap between menu and flyout |
isPointInTriangle | Hit-test a point |
pointInRect | Viewport rect hit-test |
Styling
Scoped classes:
ziteox-nested-menuziteox-nested-menu-panelziteox-nested-menu-submenuziteox-nested-menu-itemziteox-nested-menu-safe-area(debug overlay only)
Architecture notes
| Decision | Rationale |
|---|---|
showSafeArea prop | Docs and local QA only — not for production menus |
Window mousemove | Triangle must track pointer outside the menu DOM |
| No icon library | Chevrons are inline SVG |
Leaf-only onSelect | Parent items with submenus open on hover, not click |