TrayIcon
Defined in: tray.ts:158
Tray icon class and associated methods. This type constructor is private,
instead, you should use the static method TrayIcon.new
.
Unlike Rust, javascript does not have any way to run cleanup code
when an object is being removed by garbage collection, but this tray icon
will be cleaned up when the tauri app exists, however if you want to cleanup
this object early, you need to call TrayIcon.close
.
import { TrayIcon } from '@tauri-apps/api/tray';const tray = await TrayIcon.new({ tooltip: 'awesome tray tooltip' });tray.set_tooltip('new tooltip');
id:
string
Defined in: tray.ts:160
The id associated with this tray icon.
get rid():
number
Defined in: core.ts:309
number
close():
Promise
<void
>
Defined in: core.ts:321
Destroys and cleans up this resource from memory. You should not call any method on this object anymore and should drop any reference to it.
Promise
<void
>
setIcon(
icon
):Promise
<void
>
Defined in: tray.ts:224
Sets a new tray icon. If null
is provided, it will remove the icon.
Note that you may need the image-ico
or image-png
Cargo features to use this API.
To enable it, change your Cargo.toml file:
[dependencies]tauri = { version = "...", features = ["...", "image-png"] }
null
| string
| number
[] | ArrayBuffer
| Uint8Array
<ArrayBufferLike
> | Image
Promise
<void
>
setIconAsTemplate(
asTemplate
):Promise
<void
>
Defined in: tray.ts:292
Sets the current icon as a template. macOS only
boolean
Promise
<void
>
setMenu(
menu
):Promise
<void
>
Defined in: tray.ts:241
Sets a new tray menu.
- Linux: once a menu is set it cannot be removed so
null
has no effect
Promise
<void
>
setMenuOnLeftClick(
onLeft
):Promise
<void
>
Defined in: tray.ts:308
Disable or enable showing the tray menu on left click.
- Linux: Unsupported.
boolean
Promise
<void
>
setShowMenuOnLeftClick(
onLeft
):Promise
<void
>
Defined in: tray.ts:324
Disable or enable showing the tray menu on left click.
- Linux: Unsupported.
boolean
Promise
<void
>
2.2.0
setTempDirPath(
path
):Promise
<void
>
Defined in: tray.ts:287
Sets the tray icon temp dir path. Linux only.
On Linux, we need to write the icon to the disk and usually it will
be $XDG_RUNTIME_DIR/tray-icon
or $TEMP/tray-icon
.
null
| string
Promise
<void
>
setTitle(
title
):Promise
<void
>
Defined in: tray.ts:272
Sets the tooltip for this tray icon.
- Linux: The title will not be shown unless there is an icon as well. The title is useful for numerical and other frequently updated information. In general, it shouldn’t be shown unless a user requests it as it can take up a significant amount of space on the user’s panel. This may not be shown in all visualizations.
- Windows: Unsupported
null
| string
Promise
<void
>
setTooltip(
tooltip
):Promise
<void
>
Defined in: tray.ts:256
Sets the tooltip for this tray icon.
- Linux: Unsupported
null
| string
Promise
<void
>
setVisible(
visible
):Promise
<void
>
Defined in: tray.ts:277
Show or hide this tray icon.
boolean
Promise
<void
>
static
getById(id
):Promise
<null
|TrayIcon
>
Defined in: tray.ts:168
Gets a tray icon using the provided id.
string
Promise
<null
| TrayIcon
>
static
new(options?
):Promise
<TrayIcon
>
Defined in: tray.ts:192
Creates a new TrayIcon
- Linux: Sometimes the icon won’t be visible unless a menu is set.
Setting an empty
Menu
is enough.
Promise
<TrayIcon
>
static
removeById(id
):Promise
<void
>
Defined in: tray.ts:180
Removes a tray icon using the provided id from tauri’s internal state.
Note that this may cause the tray icon to disappear if it wasn’t cloned somewhere else or referenced by JS.
string
Promise
<void
>
© 2025 Tauri Contributors. CC-BY / MIT