app.createTrayIcon(), which ensures they are initialized on the native event loop.
Before you begin
Tray icons should be created after the application is ready.Creating your first tray icon
The example below creates a tray icon with two menu items.Showing and hiding the window
Many tray applications hide instead of closing.Updating the tray icon
You can replace the icon at runtime.- unread notifications
- connection status
- syncing indicators
- recording state
Updating the tooltip
Replacing the menu
Menus are not fixed after creation.Responding to clicks
Tray icons emit pointer events.custom-menu-click event.
Temporarily hiding the tray icon
Hide the icon without destroying it.Removing the tray icon
To remove the icon permanently:app.exit() automatically disposes every tray icon owned by the application.