Book Image

NW.js Essentials

By : Alessandro Benoit, Roger Weng
Book Image

NW.js Essentials

By: Alessandro Benoit, Roger Weng

Overview of this book

Table of Contents (17 chapters)
NW.js Essentials
About the Author
About the Reviewers

The Tray API – hide your application in plain sight

The system tray is a small area of the screen, usually placed on the right-hand side of the system taskbar, which contains a set of icons belonging to long-running applications or services that don't fit into the taskbar, which, otherwise, will be overcrowded.

In order to associate one or more tray icons to your application, you'll have to instance a Tray object as follows:

var gui = require('nw.gui');
var tray = new gui.Tray({
  icon: 'icon.png'

On Microsoft Windows and Linux, once you have an instance of the tray, you can add a tooltip assigning the Tray.tooltip property, change the icon at runtime using Tray.icon, or assign a menu to


The NW.js Tray API doesn't work on all Linux distributions as, at the moment, it is still using GTKStatusIcon instead of the newer AppIndicator. However, there's an open issue on GitHub, so this might change in future releases.

In order to show the menu, you'll have to right-click on the icon...