WebviewJS exposes a cross-platform menu system built on tao’s native menu APIs. On macOS the menu bar appears at the top of the screen as part of the application; on Windows it is embedded in each window’s title-bar area. Menus are defined as plain JavaScript objects describing a tree of items — no native handles or platform SDKs required. Custom items carry a stringDocumentation 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.
id that is delivered to an application event listener when the user clicks them, while predefined role items (copy, paste, undo, etc.) are handled natively by the platform without any application code.
Setting the Global Application Menu
Callapp.setMenu(options) with a MenuOptions object before or after creating windows. On macOS this controls the single app-level menu bar; on Windows it becomes the default menu for every window that doesn’t override it.
MenuOptions and MenuItemOptions
Both the top-level menu and every submenu use the sameMenuOptions shape:
role or a label+id pair. Items with a submenu act as flyout parents — they do not fire click events themselves.
Predefined Roles
Role items are handled entirely by the platform. You do not need an event listener for them.Text editing
cut · copy · paste · selectall · undo · redoWindow & app
quit · minimize · zoom · fullscreen · separatorHandling Custom Menu Clicks
Items that carry anid field fire a custom-menu-click event on the Application instance. The event payload includes both the item id and the windowId of the window that was focused when the menu was invoked.
On Linux,
CustomMenuClick events are never fired and menu rendering is not supported. Code that handles menu events should work correctly when those events are absent.Complete Menu Example
Full menu system from menu-system.mjs
Full menu system from menu-system.mjs
Nested Submenus
Nestsubmenu objects to any depth. The platform renders them as flyout panels.
Accelerator Syntax
Accelerators use a portable syntax that maps to platform-native shortcuts:Window-Specific Menus
Pass amenu option to createBrowserWindow, or call win.setMenu() after the window is created. A per-window menu overrides the global application menu for that window only. Click events still fire on Application as custom-menu-click.
- At creation time
- After creation
Updating Menus at Runtime
Replace the entire menu tree by callingapp.setMenu() again. Pass null to remove the menu completely.
Platform Differences
| Feature | Windows | macOS | Linux |
|---|---|---|---|
| Menu bar location | Inside each window’s title bar | Top of screen (app-wide) | Not supported |
| Predefined roles | Most roles supported | All roles supported | N/A |
| Keyboard accelerators | ✅ | ✅ | N/A |
custom-menu-click events | ✅ | ✅ | Never fires |
win.hasMenu() | ✅ | ✅ | Always false |