The system tray API lets you embed a persistent icon in the operating system’s notification area (macOS menu bar, Windows system tray, or Linux status area). Tray icons can carry context menus, tooltips, titles, and respond to pointer events — making them ideal for background applications, status indicators, and quick-access launchers. Tray icons must be created viaDocumentation 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.
app.createTrayIcon() so that construction always happens on the native event-loop thread.
Creating a Tray Icon
Icon data may be raw RGBA bytes paired with explicit
width and height dimensions, or an encoded image file (PNG, JPEG, ICO, etc.) supplied without dimensions. The library detects the format automatically.app.createTrayIcon(options)
Configuration object for the new tray icon.
A
TrayIcon instance that implements TypedEventEmitter<TrayEventMap> and Symbol.dispose.Properties
Read-only string identifier for the icon. Matches the
id provided in TrayIconOptions, or an auto-generated value when none was given.Methods
setIcon(icon, width?, height?)
New icon image data — either raw RGBA bytes (with dimensions) or an encoded image buffer.
Width in pixels. Required for raw RGBA data.
Height in pixels. Required for raw RGBA data.
removeIcon()
Hides the icon graphic, leaving the tray entry otherwise intact. Call setIcon() to restore it.
setMenu(menu?)
New menu configuration. Pass
null or undefined to detach the menu entirely.setTooltip(tooltip?)
New tooltip string. Pass
null or undefined to remove the tooltip.Tooltip is not supported on Linux.
setTitle(title?)
Label text to display beside the icon. Pass
null or undefined to remove it.Title is not supported on Windows.
setVisible(visible)
true to show the icon, false to hide it.setIconAsTemplate(value)
true to enable template-image rendering, false to disable it.This method is macOS-only and has no effect on other platforms.
setShowMenuOnLeftClick(value)
Whether to open the context menu on a left-click event.
Not supported on Linux.
setShowMenuOnRightClick(value)
Whether to open the context menu on a right-click event.
Not supported on Linux.
showMenu()
Programmatically opens the attached context menu, as if the user had clicked the icon. Useful for triggering the menu from application logic rather than user interaction.
rect()
Returns the bounding rectangle of the tray icon in screen coordinates, or null when the icon is hidden or the platform cannot report its position.
dispose()
Immediately removes the tray icon and releases native resources. After calling dispose(), all method calls on the instance will throw. Equivalent to the Symbol.dispose protocol for use with using.
isDisposed()
true after dispose() has been called or app.exit() has removed the icon.Events
TrayIcon implements TypedEventEmitter<TrayEventMap>. Use .on(), .once(), .off(), and the other standard EventEmitter methods to subscribe.
| Event | Payload | Notes |
|---|---|---|
click | TrayEventPayload | Single click on the icon |
double-click | TrayEventPayload | Double click on the icon |
enter | TrayEventPayload | Cursor entered the icon area |
move | TrayEventPayload | Cursor moved within the icon area |
leave | TrayEventPayload | Cursor left the icon area |
TrayEventPayload
Name of the event (e.g.
"click", "double-click").The
id of the TrayIcon that fired the event.Horizontal cursor position in physical screen pixels.
Vertical cursor position in physical screen pixels.
Bounding rectangle of the tray icon at the time of the event.
Mouse button involved (
"left", "right", "middle"). Present on click events.State of the button (
"pressed", "released"). Present on click events.Platform Notes
macOS
macOS
- The menu bar is shared across all applications; tray entries appear on the right side.
setTitle()is supported and renders inline text next to the icon.setIconAsTemplate(true)enables automatic monochrome adaptation for light/dark modes.- Both left- and right-click menu triggers are configurable.
Windows
Windows
- Icons appear in the notification area (bottom-right system tray).
setTitle()has no effect on Windows.- Tooltip and click-menu configuration are supported.
- Use a 16×16 or 32×32 pixel icon for best results.
Linux
Linux
- Tray support depends on the desktop environment and any installed system-tray extension.
- Pointer events (
click,double-click,enter,move,leave) are not emitted. - Tooltip and click-menu configuration are not supported.
- GTK status-icon or AppIndicator backends are used depending on the build.