Raxol. UI. Components. Input. Menu
(Raxol v2.6.0)
View Source
A nested menu component with keyboard navigation.
Supports flat and nested menus with the same component. Only one submenu chain can be open at a time (standard menu behavior).
Item data format:
%{id: atom, label: string, children: [item], disabled: boolean, shortcut: string | nil}children: []= leaf (selectable action item)children: [...]= submenu parentdisabled: true= rendered dimmed, skipped during navigationshortcut= optional hint text rendered right-aligned (e.g. "Ctrl+S")
Keyboard bindings:
- Up/Down: move cursor through visible items (skip disabled), clamped
- Right: open submenu of current item (if it has children)
- Left: close current submenu level, move cursor to parent
- Enter/Space: fire on_select for leaf items; open submenu for parents
- Home/End: jump to first/last visible non-disabled item
- Escape: close deepest open submenu (or pass through)
Summary
Functions
Recursively searches for an item by id.
Finds the parent of an item by id. Returns nil if it's a root item or not found.
Callback implementation for Raxol.UI.Components.Base.Component.mount/1.
Callback implementation for Raxol.UI.Components.Base.Component.unmount/1.
Callback implementation for Raxol.UI.Components.Base.Component.update/2.
Returns a flat list of {item, depth} tuples for all currently visible items,
respecting the open_path. Only the single open submenu chain is expanded.
Types
Functions
Recursively searches for an item by id.
Finds the parent of an item by id. Returns nil if it's a root item or not found.
Callback implementation for Raxol.UI.Components.Base.Component.mount/1.
Callback implementation for Raxol.UI.Components.Base.Component.unmount/1.
Callback implementation for Raxol.UI.Components.Base.Component.update/2.
@spec visible_items(t()) :: [{menu_item(), non_neg_integer()}]
Returns a flat list of {item, depth} tuples for all currently visible items,
respecting the open_path. Only the single open submenu chain is expanded.