Skip to main content
WebviewJS exposes a cross-platform native menu system powered by muda. You define a tree of menu items — labels, roles, accelerators, and submenus — and the OS renders it natively. On macOS the menu bar lives at the top of the screen and belongs to the application. On Windows each window has its own menu bar embedded in the title bar. On Linux a per-window GTK menu bar is attached through Tao’s GTK integration; custom-menu-click events fire on all three platforms. See Platform differences for details.

Setting a global menu

Call app.setMenu(options) before or after creating windows. The menu applies to all windows that do not have a per-window override.

Handling menu clicks

Listen for custom-menu-click on the Application instance. The event payload contains a customMenuEvent object with the id you assigned to the menu item and the windowId of the window that was frontmost when the item was activated.
Only items with an id property emit this event. Role-based items such as copy and paste are handled natively by the OS and do not emit custom-menu-click.

Updating menus at runtime

Replace the entire menu tree at any time by calling app.setMenu() again with a new item list. Pass null to remove the menu bar entirely.

Per-window menus

Call win.setMenu() to assign a menu that applies only to a specific window. This overrides the global menu for that window. Clicks still emit custom-menu-click on the application.

Keyboard accelerators

Specify accelerators with the accelerator property on any custom menu item. Use the following cross-platform modifier tokens:

Predefined roles

Use role instead of id + label to get OS-native behavior without writing click handlers. Role items are rendered and wired by the platform.

Nested submenus

Nest a submenu inside any top-level or secondary menu item to create hierarchical menus.

Platform differences

On Linux, WebviewJS uses Muda’s GTK integration to attach a per-window menu bar. Both app.setMenu() and win.setMenu() work, and custom-menu-click events fire as expected. The visual appearance is determined by the GTK theme of the desktop environment.