Skip to main content
Menus provide organized navigation and command access in your application. Dear ImGui supports menu bars, popup menus, and context menus.

Window Menu Bar

Add a menu bar to the current window:
Requires ImGuiWindowFlags_MenuBar flag set on the parent window.
Create a full-screen menu bar at the top:

BeginMenu() / EndMenu()

Create a sub-menu:
const char*
required
Menu label
bool
default:"true"
Whether the menu can be opened
Create a clickable menu item:
const char*
required
Menu item label
const char*
Keyboard shortcut text (for display only, not processed)
bool
Display a checkmark if true
bool
default:"true"
Whether the item can be clicked

Nested Menus

Create hierarchical menu structures:
Add visual separators between menu items:

Context Menus

BeginPopupContextItem()

Context menu for the last item:

BeginPopupContextWindow()

Context menu for the current window:

BeginPopupContextVoid()

Context menu when clicking in empty space:

Complex Menu Contents

Menus can contain any widgets:
Display color swatches in menus:

Appending to Existing Menus

You can append to menus multiple times:

Complete Example

Best Practices

Keyboard shortcuts in MenuItem() are displayed but not automatically processed. You need to implement the actual keyboard handling separately.
Use Separator() to group related menu items visually.
Always call EndMenu() only if BeginMenu() returns true. Always call EndMenuBar() only if BeginMenuBar() returns true.
Context menus default to right-click. Use ImGuiPopupFlags_MouseButtonLeft or ImGuiPopupFlags_MouseButtonMiddle for different buttons.