Menu

Post image 1
Post image 2
1 / 2
0

Building a Menubar App with Tauri v2 — What Nobody Tells You

DEV Community·hiyoyo·19 days ago
#1gleoDNP
Reading 0:00
15s threshold

All tests run on an 8-year-old MacBook Air. All results from shipping 7 Mac apps as a solo developer. No sponsored opinion. Menubar apps look simple from the outside. A tray icon, a popover, done. The actual implementation has enough edge cases that I wish someone had written this before I started. The basic setup Tauri v2 has first-class tray icon support. The fundamentals: rust use tauri::{ tray::{TrayIconBuilder, TrayIconEvent}, Manager, }; TrayIconBuilder::new() .icon(app.default_window_icon().unwrap().clone()) .on_tray_icon_event(|tray, event| { if let TrayIconEvent::Click { .. } = event { // toggle window } }) .build(app)?; Hide from Dock and App Switcher A menubar app shouldn't appear in the Dock or Cmd+Tab switcher. Set this in Info.plist: xml LSUIElement Or in tauri.conf.json: json { "bundle": { "macOS": { "infoPlist": { "LSUIElement": true } } } } Without this, users will be confused why a menubar app appears in the Dock. This is the first thing to set.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More