WebviewJS uses muda to render native menu bars on all three desktop platforms. Menus are described as plain JavaScript objects — a tree ofDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/webviewjs/webview/llms.txt
Use this file to discover all available pages before exploring further.
MenuItemOptions entries that can include labels, keyboard accelerators, predefined system roles, and nested submenus. Custom menu item clicks are reported through a single application-level event so that all windows share the same handler. The menu system integrates naturally with the rest of WebviewJS: set a global menu on app, or pass a per-window menu option when creating a BrowserWindow.
Setting a Global Application Menu
app.setMenu() is additive — calling it again replaces the previous menu entirely. Pass null to remove the global menu.app.setMenu(options?)
The new global menu configuration. Pass
null or undefined to remove the current menu.Per-Window Menu
Override the global menu for a specific window by passing amenu option to createBrowserWindow(), or by calling win.setMenu() on an existing window:
Attaches a menu to this window only, overriding the global menu.
When
true, the global application menu is shown on this window even if a per-window menu has been set.MenuItemOptions
Stable identifier emitted in the
custom-menu-click application event. Should be unique across all menu items. Items without an id (e.g. separators, role-only items) do not fire custom-menu-click.Display text for the menu item. Not required for separator or purely role-based items.
Controls whether the item is interactive. Defaults to
true. Set to false to render a greyed-out item.Keyboard shortcut string. Uses a cross-platform syntax (see Accelerator Syntax below). Examples:
"CmdOrCtrl+N", "Alt+F4", "Shift+CmdOrCtrl+Z", "F5".Nested
MenuOptions that opens as a child menu when this item is hovered or activated. When a submenu is present, id and accelerator are ignored — the item acts purely as a parent container.Assigns a predefined native behavior to the item. The platform localizes the label automatically. See Predefined Roles for the full list.
Predefined Roles
Roles map directly to native platform actions and are automatically localized. Use them instead of customid/label entries for standard OS behaviors.
| Role | Action |
|---|---|
copy | Copy selection to clipboard |
paste | Paste from clipboard |
cut | Cut selection to clipboard |
undo | Undo last action |
redo | Redo last undone action |
selectall / select-all | Select all content |
separator / - | Horizontal separator line |
minimize | Minimise the window |
maximize | Maximise the window |
fullscreen | Toggle fullscreen mode |
close / closewindow / close-window | Close the active window |
quit | Quit the application |
about | Show the about dialog |
hide | Hide the application (macOS only) |
hideothers / hide-others | Hide other applications (macOS only) |
showall / show-all | Show all hidden applications (macOS only) |
services | Open the Services submenu (macOS only) |
bringalltofront / bring-all-to-front | Bring all windows to front (macOS only) |
Handling Menu Clicks
Custom menu items (those with anid) fire the custom-menu-click event on the Application instance:
The
id set on the MenuItemOptions that was clicked.Numeric identifier of the window whose menu bar the item belongs to.
Accelerator Syntax
Accelerators follow aModifier+Key pattern. Multiple modifiers are joined with +. Key names match standard key identifiers.
| Token | Meaning |
|---|---|
CmdOrCtrl | Cmd on macOS, Ctrl on Windows and Linux |
Ctrl | Control key (all platforms) |
Alt | Alt / Option key |
Shift | Shift key |
Meta / Super | Windows key / Command key |
F1 – F12 | Function keys |
| Letter / digit | Literal key (e.g. N, S, 0) |
Platform Notes
macOS
macOS
macOS uses a single shared menu bar at the top of the screen that belongs to the frontmost application. The global menu set via
app.setMenu() is displayed for all windows. Per-window menus are possible but override the shared bar only when that window is active.Windows
Windows
Each window has its own menu bar attached to its title bar. Both global and per-window menus are rendered as a standard Win32 menu bar.
Linux
Linux
Per-window GTK menu bars are attached through Tao’s GTK window container. Behaviour depends on the desktop environment; some environments (such as those using global menu applets) may redirect the menu bar.