Tauri Core API - v2.6.0
    Preparing search index...

    Class TrayIcon

    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');

    Hierarchy (View Summary)

    Index

    Properties

    id: string

    The id associated with this tray icon.

    Accessors

    • get rid(): number

      Returns number

    Methods

    • 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.

      Returns Promise<void>

    • 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.

      Parameters

      • id: string

      Returns Promise<void>

    • 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"] }

      Parameters

      Returns Promise<void>

    • Sets a new tray menu.

      • Linux: once a menu is set it cannot be removed so null has no effect

      Parameters

      Returns Promise<void>

    • Sets the tooltip for this tray icon.

      • Linux: Unsupported

      Parameters

      • tooltip: null | string

      Returns Promise<void>

    • 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

      Parameters

      • title: null | string

      Returns Promise<void>

    • Show or hide this tray icon.

      Parameters

      • visible: boolean

      Returns Promise<void>

    • 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.

      Parameters

      • path: null | string

      Returns Promise<void>

    • Sets the current icon as a template. macOS only

      Parameters

      • asTemplate: boolean

      Returns Promise<void>

    • Disable or enable showing the tray menu on left click.

      • Linux: Unsupported.

      Parameters

      • onLeft: boolean

      Returns Promise<void>

      2.2.0