node.jselectron

Remove menubar from Electron app


How do I remove this menu-bar from my electron apps:

menu-bar

Also it says "Hello World"(is this because I downloaded electron pre-built, and will go away once I package the application?). I didn't code these into the html, so I don't know how to get it out!-


Solution

  • You can use w.setMenu(null) or set frame: false (this also removes buttons for close, minimize and maximize options) on your window. See setMenu() or BrowserWindow(). Also check this thread


    Electron now has win.removeMenu() (added in v5.0.0), to remove application menus instead of using win.setMenu(null).


    Electron 7.1.x seems to have a bug where win.removeMenu() doesn't work. The only workaround is to use Menu.setApplicationMenu(null), however, this will disable all the menu shortcuts like F11 for toggling fullscreen etc.


    In new versions of Electron, you can set autoHideMenuBar: true while creating browserWindow, pressing Alt will show the menu bar again.

    const mainWindow = new BrowserWindow({
      autoHideMenuBar: true,
    })