Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. Electron.js Desktop App Development

Lesson 27 of 28 · javascript

Menus, Application Menu & Tray Icons

Duration: 10 mins

Menus, Application Menu & Tray Icons

Create a native menu:

const { Menu } = require('electron');
const template = [
  {
    label: 'File',
    submenu: [
      { role: 'quit' }
    ]
  },
  {
    label: 'Edit',
    submenu: [
      { role: 'undo' },
      { role: 'redo' },
      { type: 'separator' },
      { role: 'copy' },
      { role: 'paste' }
    ]
  }
];
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);

Tray (system‑level icon):

const { Tray, nativeImage } = require('electron');
let tray = null;
app.whenReady().then(() => {
  const icon = nativeImage.createFromPath('assets/tray.png');
  tray = new Tray(icon);
  tray.setToolTip('My Electron App');
  tray.setContextMenu(Menu.buildFromTemplate([
    { label: 'Show', click: () => win.show() },
    { label: 'Quit', click: () => app.quit() }
  ]));
});
Previous: Loading Local HTML, Remote URLs & Custom ProtocolsNext: Inter‑process Communication (IPC)