@@ -35,7 +35,7 @@ const options = {
3535 // here you can add a tray menu, title, tooltip, event handler, etc
3636};
3737
38- const tray = TrayIcon .new (options);
38+ const tray = await TrayIcon .new (options);
3939```
4040
4141See [ ` TrayIconOptions ` ] for more information on the customization options.
@@ -62,16 +62,35 @@ See [`TrayIconBuilder`] for more information on customization options.
6262
6363### Change the Tray Icon
6464
65- { /* TODO: add a way to do this easily from JS too */ }
65+ When creating the tray you can use the application icon as the tray icon:
6666
67- When creating the tray icon from Rust code, you can set the application icon as the tray icon:
67+ <Tabs >
68+ <TabItem label = " JavaScript" >
69+
70+ ``` javascript
71+ import { TrayIcon } from ' @tauri-apps/api/tray' ;
72+ import { defaultWindowIcon } from ' @tauri-apps/api/app' ;
73+
74+ const options = {
75+ icon: await defaultWindowIcon (),
76+ };
77+
78+ const tray = await TrayIcon .new (options);
79+ ```
80+
81+ </TabItem >
82+
83+ <TabItem label = " Rust" >
6884
6985``` rust
7086let tray = TrayIconBuilder :: new ()
7187 . icon (app . default_window_icon (). unwrap (). clone ())
7288 . build (app )? ;
7389```
7490
91+ </TabItem >
92+ </Tabs >
93+
7594### Add a Menu
7695
7796To attach a menu that is displayed when the tray is clicked, you can use the ` menu ` option.
@@ -106,7 +125,7 @@ const options = {
106125 menuOnLeftClick: true ,
107126};
108127
109- const tray = TrayIcon .new (options);
128+ const tray = await TrayIcon .new (options);
110129```
111130
112131</TabItem >
@@ -244,7 +263,7 @@ const options = {
244263 },
245264};
246265
247- const tray = TrayIcon .new (options);
266+ const tray = await TrayIcon .new (options);
248267```
249268
250269See [ ` TrayIconEvent ` ] [ js TrayIconEvent ] for more information on the event payload.
0 commit comments