adding-tauri-system-tray

Implements Tauri v2 system tray icons, menus, and runtime event handling.

Updated Jun 7, 2026
One-click install
npx skills add https://github.com/dt418/better-shot-x --skill adding-tauri-system-tray-dt418
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: adding-tauri-system-tray
Source: https://github.com/dt418/better-shot-x/tree/main/.agents/skills/adding-tauri-system-tray
Command: npx skills add https://github.com/dt418/better-shot-x --skill adding-tauri-system-tray-dt418

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building a system tray (notification area) icon in a Tauri v2 desktop application involves many moving parts—feature flags, tray builders, menus, event handlers, and runtime updates—and getting any piece wrong results in a missing icon or unresponsive menu. This Skill provides complete, working Rust patterns for every tray scenario. ## Core Features & Use Cases - Tray Icon & Menu Setup: Create tray icons with tooltips, attach menus with items, separators, and submenus, and control left-click behavior. - Event Handling: Respond to menu item clicks and tray icon mouse events (click, double-click) to show, hide, or focus windows and quit the app. - Runtime Updates: Update tray icons, tooltips, menu item text/enabled state, or replace the entire menu dynamically via Tauri commands. - Use Case: You are building a screenshot tool that lives in the system tray. Use this Skill to add a tray icon with Show/Hide/Quit menu items, toggle window visibility on left-click, and update the tooltip when recording starts. ## Quick Start Add a system tray icon to my Tauri v2 app with a menu containing Show Window, Hide Window, and Quit items, and toggle the main window when the tray icon is left-clicked.

Frequently Asked Questions about adding-tauri-system-tray

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a system tray icon in Tauri v2?

Enable the tray-icon feature in Cargo.toml, then use TrayIconBuilder inside the setup hook with an icon and tooltip. Call TrayIconBuilder::with_id if you need to reference the tray later via app.tray_by_id().

How to create a tray menu with items in Tauri?

Create MenuItem instances with MenuItem::with_id, combine them with Menu::with_items, and attach the menu via .menu(&menu) on the TrayIconBuilder. Separators and submenus are supported through PredefinedMenuItem and Submenu.

How do I handle tray icon click events in Tauri?

Attach .on_tray_icon_event to the TrayIconBuilder and match on TrayIconEvent::Click with MouseButton and MouseButtonState. Use tray.app_handle() to access windows and call show, hide, or set_focus.

Does Tauri tray support all mouse events on Linux?

No. On Linux, the Enter, Move, and Leave tray events are not supported, while click and double-click events work. Windows and macOS support the full set of tray events.

Why is my Tauri tray icon not appearing?

The tray icon fails to appear when the tray-icon feature is missing from Cargo.toml, the icon file is invalid, or build() is not called on the TrayIconBuilder. Verify all three and ensure the builder result is stored.

How do I update the tray menu at runtime in Tauri?

Store the Menu in managed state, then use menu.get(item_id) to modify item text or enabled state. To replace the whole menu, build a new Menu and call tray.set_menu(Some(menu)) after retrieving the tray with tray_by_id.