Browse documentation

Menus and dropdowns

Offer contextual commands, application menus, or a menu-backed choice.

Import

Load the optional component layer before using the examples below.

Ruby
require "zaniah/ui"

Anchored menus

Use Menu at a specific point or element. ContextMenu shares the command model.

Rendered example
Open menu overlay with enabled and disabled commands.
Rendered by Zaniah's headless backend.
Ruby
items = [["Open", open_file], ["Unavailable", nil]]
point = Zaniah::Point.new(280, 100)
Zaniah::UI::Menu.new(items, anchor: point)
Zaniah::UI::ContextMenu.new(items, anchor: point)

API summary

Constructor options and behaviors are drawn from the component reference.

ComponentConstructor and methodsVariants or behavior
ContextMenu, Menu(items, anchor:, open:)pointer + arrows/Home/End/Enter/Esc
MenuBar(menus) or .from(app.menu_bar)declarative menu model or legacy pairs
Dropdown(label, items:, value:); on_changemenu-backed

Accessibility

Menu items support arrows, Home, End, Enter, and Escape. Disabled commands remain visible.

ComponentSemantic role
ContextMenu, Menumenu/menuitem
MenuBarmenubar
Dropdownbutton