Skip to content

@tauri-apps/api/menu

Build native application, window and context menus.

A Menu holds items (MenuItem, CheckMenuItem, IconMenuItem, PredefinedMenuItem) and Submenus. Use Menu.setAsAppMenu() for the macOS application menu, Menu.setAsWindowMenu() for the Windows/Linux window menu bar, or Menu.popup() for a context menu.

Menus live on the Rust side, the frontend only holds handles to them, so keep a reference to a menu for as long as it is in use.

This package is also accessible with window.__TAURI__.menu when app.withGlobalTauri in tauri.conf.json is set to true.

All commands used by this module are part of the core:menu:default permission set, which is enabled by default, so no extra capability configuration is needed. Menu item icons additionally require the image-png / image-ico Cargo features of the tauri crate.

Defined in: packages/api/src/menu/iconMenuItem.ts:17

A native Icon to be used for the menu item

Platform-specific

  • Windows / Linux: Unsupported.
Enumeration Member Value Description Defined in
Add "Add" An add item template image. packages/api/src/menu/iconMenuItem.ts:19
Advanced "Advanced" Advanced preferences toolbar icon for the preferences window. packages/api/src/menu/iconMenuItem.ts:21
Bluetooth "Bluetooth" A Bluetooth template image. packages/api/src/menu/iconMenuItem.ts:23
Bookmarks "Bookmarks" Bookmarks image suitable for a template. packages/api/src/menu/iconMenuItem.ts:25
Caution "Caution" A caution image. packages/api/src/menu/iconMenuItem.ts:27
ColorPanel "ColorPanel" A color panel toolbar icon. packages/api/src/menu/iconMenuItem.ts:29
ColumnView "ColumnView" A column view mode template image. packages/api/src/menu/iconMenuItem.ts:31
Computer "Computer" A computer icon. packages/api/src/menu/iconMenuItem.ts:33
EnterFullScreen "EnterFullScreen" An enter full-screen mode template image. packages/api/src/menu/iconMenuItem.ts:35
Everyone "Everyone" Permissions for all users. packages/api/src/menu/iconMenuItem.ts:37
ExitFullScreen "ExitFullScreen" An exit full-screen mode template image. packages/api/src/menu/iconMenuItem.ts:39
FlowView "FlowView" A cover flow view mode template image. packages/api/src/menu/iconMenuItem.ts:41
Folder "Folder" A folder image. packages/api/src/menu/iconMenuItem.ts:43
FolderBurnable "FolderBurnable" A burnable folder icon. packages/api/src/menu/iconMenuItem.ts:45
FolderSmart "FolderSmart" A smart folder icon. packages/api/src/menu/iconMenuItem.ts:47
FollowLinkFreestanding "FollowLinkFreestanding" A link template image. packages/api/src/menu/iconMenuItem.ts:49
FontPanel "FontPanel" A font panel toolbar icon. packages/api/src/menu/iconMenuItem.ts:51
GoLeft "GoLeft" A go back template image. packages/api/src/menu/iconMenuItem.ts:53
GoRight "GoRight" A go forward template image. packages/api/src/menu/iconMenuItem.ts:55
Home "Home" Home image suitable for a template. packages/api/src/menu/iconMenuItem.ts:57
IChatTheater "IChatTheater" An iChat Theater template image. packages/api/src/menu/iconMenuItem.ts:59
IconView "IconView" An icon view mode template image. packages/api/src/menu/iconMenuItem.ts:61
Info "Info" An information toolbar icon. packages/api/src/menu/iconMenuItem.ts:63
InvalidDataFreestanding "InvalidDataFreestanding" A template image used to denote invalid data. packages/api/src/menu/iconMenuItem.ts:65
LeftFacingTriangle "LeftFacingTriangle" A generic left-facing triangle template image. packages/api/src/menu/iconMenuItem.ts:67
ListView "ListView" A list view mode template image. packages/api/src/menu/iconMenuItem.ts:69
LockLocked "LockLocked" A locked padlock template image. packages/api/src/menu/iconMenuItem.ts:71
LockUnlocked "LockUnlocked" An unlocked padlock template image. packages/api/src/menu/iconMenuItem.ts:73
MenuMixedState "MenuMixedState" A horizontal dash, for use in menus. packages/api/src/menu/iconMenuItem.ts:75
MenuOnState "MenuOnState" A check mark template image, for use in menus. packages/api/src/menu/iconMenuItem.ts:77
MobileMe "MobileMe" A MobileMe icon. packages/api/src/menu/iconMenuItem.ts:79
MultipleDocuments "MultipleDocuments" A drag image for multiple items. packages/api/src/menu/iconMenuItem.ts:81
Network "Network" A network icon. packages/api/src/menu/iconMenuItem.ts:83
Path "Path" A path button template image. packages/api/src/menu/iconMenuItem.ts:85
PreferencesGeneral "PreferencesGeneral" General preferences toolbar icon for the preferences window. packages/api/src/menu/iconMenuItem.ts:87
QuickLook "QuickLook" A Quick Look template image. packages/api/src/menu/iconMenuItem.ts:89
Refresh "Refresh" A refresh template image. packages/api/src/menu/iconMenuItem.ts:93
RefreshFreestanding "RefreshFreestanding" A refresh template image. packages/api/src/menu/iconMenuItem.ts:91
Remove "Remove" A remove item template image. packages/api/src/menu/iconMenuItem.ts:95
RevealFreestanding "RevealFreestanding" A reveal contents template image. packages/api/src/menu/iconMenuItem.ts:97
RightFacingTriangle "RightFacingTriangle" A generic right-facing triangle template image. packages/api/src/menu/iconMenuItem.ts:99
Share "Share" A share view template image. packages/api/src/menu/iconMenuItem.ts:101
Slideshow "Slideshow" A slideshow template image. packages/api/src/menu/iconMenuItem.ts:103
SmartBadge "SmartBadge" A badge for a smart item. packages/api/src/menu/iconMenuItem.ts:105
StatusAvailable "StatusAvailable" Small green indicator, similar to iChat’s available image. packages/api/src/menu/iconMenuItem.ts:107
StatusNone "StatusNone" Small clear indicator. packages/api/src/menu/iconMenuItem.ts:109
StatusPartiallyAvailable "StatusPartiallyAvailable" Small yellow indicator, similar to iChat’s idle image. packages/api/src/menu/iconMenuItem.ts:111
StatusUnavailable "StatusUnavailable" Small red indicator, similar to iChat’s unavailable image. packages/api/src/menu/iconMenuItem.ts:113
StopProgress "StopProgress" A stop progress button template image. packages/api/src/menu/iconMenuItem.ts:117
StopProgressFreestanding "StopProgressFreestanding" A stop progress template image. packages/api/src/menu/iconMenuItem.ts:115
TrashEmpty "TrashEmpty" An image of the empty trash can. packages/api/src/menu/iconMenuItem.ts:119
TrashFull "TrashFull" An image of the full trash can. packages/api/src/menu/iconMenuItem.ts:121
User "User" Permissions for a single user. packages/api/src/menu/iconMenuItem.ts:123
UserAccounts "UserAccounts" User account toolbar icon for the preferences window. packages/api/src/menu/iconMenuItem.ts:125
UserGroup "UserGroup" Permissions for a group of users. packages/api/src/menu/iconMenuItem.ts:127
UserGuest "UserGuest" Permissions for guests. packages/api/src/menu/iconMenuItem.ts:129

Defined in: packages/api/src/menu/checkMenuItem.ts:20

A check menu item inside a Menu or Submenu and usually contains a text and a check mark or a similar toggle that corresponds to a checked and unchecked states.

  • MenuItemBase

get id(): string;

Defined in: packages/api/src/menu/base.ts:154

The id of this item.

string

MenuItemBase.id

get rid(): number;

Defined in: packages/api/src/core.ts:560

number

MenuItemBase.rid

asyncDispose: Promise<void>;

Defined in: packages/api/src/core.ts:581

Promise<void>

MenuItemBase.[asyncDispose]

close(): Promise<void>;

Defined in: packages/api/src/core.ts:575

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>

Uses the core:resources:allow-close permission, which is part of the core:resources:default permission set enabled by default.

MenuItemBase.close

isChecked(): Promise<boolean>;

Defined in: packages/api/src/menu/checkMenuItem.ts:75

Returns whether this check menu item is checked or not.

Promise<boolean>

isEnabled(): Promise<boolean>;

Defined in: packages/api/src/menu/checkMenuItem.ts:48

Returns whether this check menu item is enabled or not.

Promise<boolean>

setAccelerator(accelerator: string | null): Promise<void>;

Defined in: packages/api/src/menu/checkMenuItem.ts:66

Sets the accelerator for this check menu item, or removes it when given null.

See MenuItemOptions.accelerator for the accepted format.

Parameter Type
accelerator string | null

Promise<void>

setChecked(checked: boolean): Promise<void>;

Defined in: packages/api/src/menu/checkMenuItem.ts:80

Sets whether this check menu item is checked or not.

Parameter Type
checked boolean

Promise<void>

setEnabled(enabled: boolean): Promise<void>;

Defined in: packages/api/src/menu/checkMenuItem.ts:53

Sets whether this check menu item is enabled or not.

Parameter Type
enabled boolean

Promise<void>

setText(text: string): Promise<void>;

Defined in: packages/api/src/menu/checkMenuItem.ts:39

Sets the text for this check menu item.

Parameter Type
text string

Promise<void>

text(): Promise<string>;

Defined in: packages/api/src/menu/checkMenuItem.ts:34

Returns the text of this check menu item.

Promise<string>

static new(opts: CheckMenuItemOptions): Promise<CheckMenuItem>;

Defined in: packages/api/src/menu/checkMenuItem.ts:27

Create a new check menu item.

Parameter Type
opts CheckMenuItemOptions

Promise<CheckMenuItem>


Defined in: packages/api/src/menu/iconMenuItem.ts:151

An icon menu item inside a Menu or Submenu and usually contains an icon and a text.

  • MenuItemBase

get id(): string;

Defined in: packages/api/src/menu/base.ts:154

The id of this item.

string

MenuItemBase.id

get rid(): number;

Defined in: packages/api/src/core.ts:560

number

MenuItemBase.rid

asyncDispose: Promise<void>;

Defined in: packages/api/src/core.ts:581

Promise<void>

MenuItemBase.[asyncDispose]

close(): Promise<void>;

Defined in: packages/api/src/core.ts:575

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>

Uses the core:resources:allow-close permission, which is part of the core:resources:default permission set enabled by default.

MenuItemBase.close

isEnabled(): Promise<boolean>;

Defined in: packages/api/src/menu/iconMenuItem.ts:177

Returns whether this icon menu item is enabled or not.

Promise<boolean>

setAccelerator(accelerator: string | null): Promise<void>;

Defined in: packages/api/src/menu/iconMenuItem.ts:195

Sets the accelerator for this icon menu item, or removes it when given null.

See MenuItemOptions.accelerator for the accepted format.

Parameter Type
accelerator string | null

Promise<void>

setEnabled(enabled: boolean): Promise<void>;

Defined in: packages/api/src/menu/iconMenuItem.ts:182

Sets whether this icon menu item is enabled or not.

Parameter Type
enabled boolean

Promise<void>

setIcon(icon: MenuIcon | null): Promise<void>;

Defined in: packages/api/src/menu/iconMenuItem.ts:204

Sets an icon for this icon menu item

Parameter Type
icon MenuIcon | null

Promise<void>

setText(text: string): Promise<void>;

Defined in: packages/api/src/menu/iconMenuItem.ts:168

Sets the text for this icon menu item.

Parameter Type
text string

Promise<void>

text(): Promise<string>;

Defined in: packages/api/src/menu/iconMenuItem.ts:163

Returns the text of this icon menu item.

Promise<string>

static new(opts: IconMenuItemOptions): Promise<IconMenuItem>;

Defined in: packages/api/src/menu/iconMenuItem.ts:158

Create a new icon menu item.

Parameter Type
opts IconMenuItemOptions

Promise<IconMenuItem>


Defined in: packages/api/src/menu/menu.ts:48

A type that is either a menu bar on the window on Windows and Linux or as a global menu in the menubar on macOS.

Platform-specific

  • macOS: if using Menu for the global menubar, it can only contain Submenus.
  • MenuItemBase

get id(): string;

Defined in: packages/api/src/menu/base.ts:154

The id of this item.

string

MenuItemBase.id

get rid(): number;

Defined in: packages/api/src/core.ts:560

number

MenuItemBase.rid

asyncDispose: Promise<void>;

Defined in: packages/api/src/core.ts:581

Promise<void>

MenuItemBase.[asyncDispose]

append<T extends
| Submenu
| MenuItem
| PredefinedMenuItem
| CheckMenuItem
| IconMenuItem
| MenuItemOptions
| SubmenuOptions
| IconMenuItemOptions
| PredefinedMenuItemOptions
| CheckMenuItemOptions>(items: T | T[]): Promise<void>;

Defined in: packages/api/src/menu/menu.ts:117

Add a menu item to the end of this menu.

Platform-specific

Type Parameter
T extends | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions
Parameter Type
items T | T[]

Promise<void>

close(): Promise<void>;

Defined in: packages/api/src/core.ts:575

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>

Uses the core:resources:allow-close permission, which is part of the core:resources:default permission set enabled by default.

MenuItemBase.close

get(id: string): Promise<
| Submenu
| MenuItem
| PredefinedMenuItem
| CheckMenuItem
| IconMenuItem
| null>;

Defined in: packages/api/src/menu/menu.ts:234

Retrieves the menu item matching the given identifier.

Parameter Type
id string

Promise< | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | null>

insert<T extends
| Submenu
| MenuItem
| PredefinedMenuItem
| CheckMenuItem
| IconMenuItem
| MenuItemOptions
| SubmenuOptions
| IconMenuItemOptions
| PredefinedMenuItemOptions
| CheckMenuItemOptions>(items: T | T[], position: number): Promise<void>;

Defined in: packages/api/src/menu/menu.ts:171

Add a menu item to the specified position in this menu.

Platform-specific

Type Parameter
T extends | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions
Parameter Type
items T | T[]
position number

Promise<void>

items(): Promise<(
| Submenu
| MenuItem
| PredefinedMenuItem
| CheckMenuItem
| IconMenuItem)[]>;

Defined in: packages/api/src/menu/menu.ts:222

Returns a list of menu items that has been added to this menu.

Promise<( | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem)[]>

popup(at?: PhysicalPosition | LogicalPosition | Position, window?: Window): Promise<void>;

Defined in: packages/api/src/menu/menu.ts:278

Popup this menu as a context menu on the specified window.

Call it from a contextmenu DOM listener (and preventDefault() on the event) to replace the webview context menu with a native one. The promise resolves as soon as the menu is shown, not when an item is picked: use each item’s action handler for that.

import { Menu } from '@tauri-apps/api/menu';
import { LogicalPosition } from '@tauri-apps/api/dpi';
const menu = await Menu.new({
items: [{ id: 'copy', text: 'Copy', action: () => console.log('copy') }]
});
document.addEventListener('contextmenu', (event) => {
event.preventDefault();
void menu.popup(new LogicalPosition(event.clientX, event.clientY));
});
Parameter Type Description
at? | PhysicalPosition | LogicalPosition | Position If a position is provided, it is relative to the window’s top-left corner. If there isn’t one provided, the menu will pop up at the current location of the mouse.
window? Window The window to show the menu on. Defaults to the current window.

Promise<void>

prepend<T extends
| Submenu
| MenuItem
| PredefinedMenuItem
| CheckMenuItem
| IconMenuItem
| MenuItemOptions
| SubmenuOptions
| IconMenuItemOptions
| PredefinedMenuItemOptions
| CheckMenuItemOptions>(items: T | T[]): Promise<void>;

Defined in: packages/api/src/menu/menu.ts:144

Add a menu item to the beginning of this menu.

Platform-specific

Type Parameter
T extends | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions
Parameter Type
items T | T[]

Promise<void>

remove(item: Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem): Promise<void>;

Defined in: packages/api/src/menu/menu.ts:193

Remove a menu item from this menu.

Parameter Type
item | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem

Promise<void>

removeAt(position: number): Promise<
| Submenu
| MenuItem
| PredefinedMenuItem
| CheckMenuItem
| IconMenuItem
| null>;

Defined in: packages/api/src/menu/menu.ts:204

Remove a menu item from this menu at the specified position.

Parameter Type
position number

Promise< | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | null>

setAsAppMenu(): Promise<Menu | null>;

Defined in: packages/api/src/menu/menu.ts:311

Sets the app-wide menu and returns the previous one.

If a window was not created with an explicit menu or had one set explicitly, this menu will be assigned to it.

This is the menu bar shown at the top of the screen on macOS. On Windows and Linux, where menus belong to a window, use Menu.setAsWindowMenu to target one window instead.

import { Menu } from '@tauri-apps/api/menu';
await using menu = await Menu.default();
const previous = await menu.setAsAppMenu();
await previous?.close();

Promise<Menu | null>

The menu that was set before this call, or null if there was none.

setAsWindowMenu(window?: Window): Promise<Menu | null>;

Defined in: packages/api/src/menu/menu.ts:337

Sets the window menu and returns the previous one.

Platform-specific

  • macOS: Unsupported. The menu on macOS is app-wide and not specific to one window, if you need to set it, use Menu.setAsAppMenu instead.
import { Menu } from '@tauri-apps/api/menu';
import { getCurrentWindow } from '@tauri-apps/api/window';
await using menu = await Menu.default();
await menu.setAsWindowMenu(getCurrentWindow());
Parameter Type Description
window? Window The window to set the menu on. Defaults to the current window.

Promise<Menu | null>

The menu that was set on that window before this call, or null if there was none.

static default(): Promise<Menu>;

Defined in: packages/api/src/menu/menu.ts:104

Create the default application menu, the same one Tauri installs when no menu is configured.

It contains an Edit submenu (undo, redo, cut, copy, paste, select all), a Window submenu (minimize, maximize, close window) and a Help submenu, plus:

  • macOS: an application submenu named after your app (about, services, hide, hide others, quit) and a View submenu with the fullscreen item.
  • Windows: a File submenu with close window and quit; the about item lives in Help.
  • Linux: no File submenu; the about item lives in Help.

Useful as a starting point you then extend with Menu.append, Menu.insert or Menu.prepend.

import { Menu } from '@tauri-apps/api/menu';
await using menu = await Menu.default();
await menu.append({ text: 'Tools', items: [{ id: 'fmt', text: 'Format' }] });
await menu.setAsAppMenu();

Promise<Menu>

static new(opts?: MenuOptions): Promise<Menu>;

Defined in: packages/api/src/menu/menu.ts:75

Create a new menu.

import { Menu } from '@tauri-apps/api/menu';
const menu = await Menu.new({
items: [
{
text: 'File',
items: [
{ id: 'open', text: 'Open', accelerator: 'CmdOrCtrl+O', action: () => console.log('open') },
{ item: 'Separator' },
{ item: 'Quit' }
]
}
]
});
Parameter Type
opts? MenuOptions

Promise<Menu>


Defined in: packages/api/src/menu/menuItem.ts:70

A menu item inside a Menu or Submenu and contains only text.

  • MenuItemBase

get id(): string;

Defined in: packages/api/src/menu/base.ts:154

The id of this item.

string

MenuItemBase.id

get rid(): number;

Defined in: packages/api/src/core.ts:560

number

MenuItemBase.rid

asyncDispose: Promise<void>;

Defined in: packages/api/src/core.ts:581

Promise<void>

MenuItemBase.[asyncDispose]

close(): Promise<void>;

Defined in: packages/api/src/core.ts:575

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>

Uses the core:resources:allow-close permission, which is part of the core:resources:default permission set enabled by default.

MenuItemBase.close

isEnabled(): Promise<boolean>;

Defined in: packages/api/src/menu/menuItem.ts:96

Returns whether this menu item is enabled or not.

Promise<boolean>

setAccelerator(accelerator: string | null): Promise<void>;

Defined in: packages/api/src/menu/menuItem.ts:119

Sets the accelerator for this menu item, or removes it when given null.

See MenuItemOptions.accelerator for the accepted format.

await item.setAccelerator('CmdOrCtrl+Shift+K');
Parameter Type
accelerator string | null

Promise<void>

setEnabled(enabled: boolean): Promise<void>;

Defined in: packages/api/src/menu/menuItem.ts:101

Sets whether this menu item is enabled or not.

Parameter Type
enabled boolean

Promise<void>

setText(text: string): Promise<void>;

Defined in: packages/api/src/menu/menuItem.ts:87

Sets the text for this menu item.

Parameter Type
text string

Promise<void>

text(): Promise<string>;

Defined in: packages/api/src/menu/menuItem.ts:82

Returns the text of this menu item.

Promise<string>

static new(opts: MenuItemOptions): Promise<MenuItem>;

Defined in: packages/api/src/menu/menuItem.ts:77

Create a new menu item.

Parameter Type
opts MenuItemOptions

Promise<MenuItem>


Defined in: packages/api/src/menu/predefinedMenuItem.ts:167

A predefined (native) menu item which has a predefined behavior by the OS or by tauri.

  • MenuItemBase

get id(): string;

Defined in: packages/api/src/menu/base.ts:154

The id of this item.

string

MenuItemBase.id

get rid(): number;

Defined in: packages/api/src/core.ts:560

number

MenuItemBase.rid

asyncDispose: Promise<void>;

Defined in: packages/api/src/core.ts:581

Promise<void>

MenuItemBase.[asyncDispose]

close(): Promise<void>;

Defined in: packages/api/src/core.ts:575

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>

Uses the core:resources:allow-close permission, which is part of the core:resources:default permission set enabled by default.

MenuItemBase.close

setText(text: string): Promise<void>;

Defined in: packages/api/src/menu/predefinedMenuItem.ts:196

Sets the text for this predefined menu item.

Parameter Type
text string

Promise<void>

text(): Promise<string>;

Defined in: packages/api/src/menu/predefinedMenuItem.ts:191

Returns the text of this predefined menu item.

Promise<string>

static new(opts?: PredefinedMenuItemOptions): Promise<PredefinedMenuItem>;

Defined in: packages/api/src/menu/predefinedMenuItem.ts:182

Create a new predefined menu item.

import { PredefinedMenuItem } from '@tauri-apps/api/menu';
const separator = await PredefinedMenuItem.new({ item: 'Separator' });
Parameter Type
opts? PredefinedMenuItemOptions

Promise<PredefinedMenuItem>


Defined in: packages/api/src/menu/submenu.ts:60

A type that is a submenu inside a Menu or Submenu.

  • MenuItemBase

get id(): string;

Defined in: packages/api/src/menu/base.ts:154

The id of this item.

string

MenuItemBase.id

get rid(): number;

Defined in: packages/api/src/core.ts:560

number

MenuItemBase.rid

asyncDispose: Promise<void>;

Defined in: packages/api/src/core.ts:581

Promise<void>

MenuItemBase.[asyncDispose]

append<T extends
| Submenu
| MenuItem
| PredefinedMenuItem
| CheckMenuItem
| IconMenuItem
| MenuItemOptions
| SubmenuOptions
| IconMenuItemOptions
| PredefinedMenuItemOptions
| CheckMenuItemOptions>(items: T | T[]): Promise<void>;

Defined in: packages/api/src/menu/submenu.ts:106

Add a menu item to the end of this submenu.

Platform-specific

Type Parameter
T extends | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions
Parameter Type
items T | T[]

Promise<void>

close(): Promise<void>;

Defined in: packages/api/src/core.ts:575

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>

Uses the core:resources:allow-close permission, which is part of the core:resources:default permission set enabled by default.

MenuItemBase.close

get(id: string): Promise<
| Submenu
| MenuItem
| PredefinedMenuItem
| CheckMenuItem
| IconMenuItem
| null>;

Defined in: packages/api/src/menu/submenu.ts:223

Retrieves the menu item matching the given identifier.

Parameter Type
id string

Promise< | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | null>

insert<T extends
| Submenu
| MenuItem
| PredefinedMenuItem
| CheckMenuItem
| IconMenuItem
| MenuItemOptions
| SubmenuOptions
| IconMenuItemOptions
| PredefinedMenuItemOptions
| CheckMenuItemOptions>(items: T | T[], position: number): Promise<void>;

Defined in: packages/api/src/menu/submenu.ts:160

Add a menu item to the specified position in this submenu.

Platform-specific

Type Parameter
T extends | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions
Parameter Type
items T | T[]
position number

Promise<void>

isEnabled(): Promise<boolean>;

Defined in: packages/api/src/menu/submenu.ts:86

Returns whether this submenu is enabled or not.

Promise<boolean>

items(): Promise<(
| Submenu
| MenuItem
| PredefinedMenuItem
| CheckMenuItem
| IconMenuItem)[]>;

Defined in: packages/api/src/menu/submenu.ts:211

Returns a list of menu items that has been added to this submenu.

Promise<( | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem)[]>

popup(at?: PhysicalPosition | LogicalPosition, window?: Window): Promise<void>;

Defined in: packages/api/src/menu/submenu.ts:245

Popup this submenu as a context menu on the specified window.

If the position, is provided, it is relative to the window’s top-left corner.

Parameter Type
at? | PhysicalPosition | LogicalPosition
window? Window

Promise<void>

prepend<T extends
| Submenu
| MenuItem
| PredefinedMenuItem
| CheckMenuItem
| IconMenuItem
| MenuItemOptions
| SubmenuOptions
| IconMenuItemOptions
| PredefinedMenuItemOptions
| CheckMenuItemOptions>(items: T | T[]): Promise<void>;

Defined in: packages/api/src/menu/submenu.ts:133

Add a menu item to the beginning of this submenu.

Platform-specific

Type Parameter
T extends | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions
Parameter Type
items T | T[]

Promise<void>

remove(item: Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem): Promise<void>;

Defined in: packages/api/src/menu/submenu.ts:182

Remove a menu item from this submenu.

Parameter Type
item | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem

Promise<void>

removeAt(position: number): Promise<
| Submenu
| MenuItem
| PredefinedMenuItem
| CheckMenuItem
| IconMenuItem
| null>;

Defined in: packages/api/src/menu/submenu.ts:193

Remove a menu item from this submenu at the specified position.

Parameter Type
position number

Promise< | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | null>

setAsHelpMenuForNSApp(): Promise<void>;

Defined in: packages/api/src/menu/submenu.ts:285

Set this submenu as the Help menu for the application on macOS.

This will cause macOS to automatically add a search box to the menu.

If no menu is set as the Help menu, macOS will automatically use any menu which has a title matching the localized word “Help”.

Platform-specific

  • Windows / Linux: Unsupported.

Promise<void>

setAsWindowsMenuForNSApp(): Promise<void>;

Defined in: packages/api/src/menu/submenu.ts:267

Set this submenu as the Window menu for the application on macOS.

This will cause macOS to automatically add window-switching items and certain other items to the menu.

Platform-specific

  • Windows / Linux: Unsupported.

Promise<void>

setEnabled(enabled: boolean): Promise<void>;

Defined in: packages/api/src/menu/submenu.ts:91

Sets whether this submenu is enabled or not.

Parameter Type
enabled boolean

Promise<void>

setIcon(icon: MenuIcon | null): Promise<void>;

Defined in: packages/api/src/menu/submenu.ts:292

Sets an icon for this submenu

Parameter Type
icon MenuIcon | null

Promise<void>

setText(text: string): Promise<void>;

Defined in: packages/api/src/menu/submenu.ts:77

Sets the text for this submenu.

Parameter Type
text string

Promise<void>

text(): Promise<string>;

Defined in: packages/api/src/menu/submenu.ts:72

Returns the text of this submenu.

Promise<string>

static new(opts: SubmenuOptions): Promise<Submenu>;

Defined in: packages/api/src/menu/submenu.ts:67

Create a new submenu.

Parameter Type
opts SubmenuOptions

Promise<Submenu>

Defined in: packages/api/src/menu/predefinedMenuItem.ts:10

A metadata for the about predefined menu item.

Property Type Description Defined in
authors? string[] The authors of the application. Platform-specific - macOS: Unsupported. packages/api/src/menu/predefinedMenuItem.ts:30
comments? string Application comments. Platform-specific - macOS: Unsupported. packages/api/src/menu/predefinedMenuItem.ts:38
copyright? string The copyright of the application. packages/api/src/menu/predefinedMenuItem.ts:40
credits? string The credits. Platform-specific - Windows / Linux: Unsupported. packages/api/src/menu/predefinedMenuItem.ts:72
icon? JsImage The application icon. Platform-specific - Windows: Unsupported. packages/api/src/menu/predefinedMenuItem.ts:80
license? string The license of the application. Platform-specific - macOS: Unsupported. packages/api/src/menu/predefinedMenuItem.ts:48
name? string Sets the application name. packages/api/src/menu/predefinedMenuItem.ts:12
shortVersion? string The short version, e.g. “1.0”. Platform-specific - Windows / Linux: Appended to the end of version in parentheses. packages/api/src/menu/predefinedMenuItem.ts:22
version? string The application version. packages/api/src/menu/predefinedMenuItem.ts:14
website? string The application website. Platform-specific - macOS: Unsupported. packages/api/src/menu/predefinedMenuItem.ts:56
websiteLabel? string The website label. Platform-specific - macOS: Unsupported. packages/api/src/menu/predefinedMenuItem.ts:64

Defined in: packages/api/src/menu/checkMenuItem.ts:10

Options for creating a new check menu item.

Property Type Description Inherited from Defined in
accelerator? string Specify an accelerator (keyboard shortcut) for the new menu item, for example 'CmdOrCtrl+Shift+K'. The string is a list of zero or more modifiers followed by exactly one key, joined with +. Matching is case insensitive and spaces around each token are ignored, so 'CmdOrCtrl+Shift+K' and 'cmdorctrl + shift + k' are equivalent. All modifiers must come before the key. Accepted modifiers: - Shift - Control, Ctrl - Alt, Option - Command, Cmd, Super - CmdOrCtrl, CmdOrControl, CommandOrCtrl, CommandOrControl — Command on macOS and Control everywhere else, which is what you usually want for application shortcuts. Accepted keys: - Letters A-Z (also written KeyA-KeyZ) and digits 0-9 (also Digit0-Digit9). - Punctuation, either as the character or by name: `/Backquote, \/Backslash, [/BracketLeft, ]/BracketRight, ,/Comma, =/Equal, -/Minus, ./Period, '/Quote, ;/Semicolon, //Slash. - Backspace, CapsLock, Enter, Space, Tab, Delete, End, Home, Insert, PageDown, PageUp, PrintScreen, ScrollLock, NumLock, Escape (also Esc). - Arrows: ArrowUp, ArrowDown, ArrowLeft, ArrowRight (also Up, Down, Left, Right). - Function keys F1 through F24. - Numpad keys: Numpad0-Numpad9 (also Num0-Num9), NumpadAdd, NumpadSubtract, NumpadMultiply, NumpadDivide, NumpadDecimal, NumpadEnter, NumpadEqual (each also accepted with the Num prefix, e.g. NumAdd). - Media keys: AudioVolumeUp, AudioVolumeDown, AudioVolumeMute (also VolumeUp, VolumeDown, VolumeMute). Example import { MenuItem } from '@tauri-apps/api/menu'; await MenuItem.new({ text: 'Find', accelerator: 'CmdOrCtrl+F' }); await MenuItem.new({ text: 'Command palette', accelerator: 'CmdOrCtrl+Shift+P' }); await MenuItem.new({ text: 'Refresh', accelerator: 'F5' }); An accelerator that cannot be parsed is ignored and the item is created without a shortcut, so double-check the spelling of the modifiers and key. MenuItemOptions.accelerator packages/api/src/menu/menuItem.ts:64
action? (id: string) => void Specify a handler to be called when this menu item is activated. MenuItemOptions.action packages/api/src/menu/menuItem.ts:66
checked? boolean Whether the new check menu item is enabled or not. - packages/api/src/menu/checkMenuItem.ts:12
enabled? boolean Whether the new menu item is enabled or not. MenuItemOptions.enabled packages/api/src/menu/menuItem.ts:15
id? string Specify an id to use for the new menu item. MenuItemOptions.id packages/api/src/menu/menuItem.ts:11
text string The text of the new menu item. MenuItemOptions.text packages/api/src/menu/menuItem.ts:13

Defined in: packages/api/src/menu/iconMenuItem.ts:133

Options for creating a new icon menu item.

Property Type Description Inherited from Defined in
accelerator? string Specify an accelerator (keyboard shortcut) for the new menu item, for example 'CmdOrCtrl+Shift+K'. The string is a list of zero or more modifiers followed by exactly one key, joined with +. Matching is case insensitive and spaces around each token are ignored, so 'CmdOrCtrl+Shift+K' and 'cmdorctrl + shift + k' are equivalent. All modifiers must come before the key. Accepted modifiers: - Shift - Control, Ctrl - Alt, Option - Command, Cmd, Super - CmdOrCtrl, CmdOrControl, CommandOrCtrl, CommandOrControl — Command on macOS and Control everywhere else, which is what you usually want for application shortcuts. Accepted keys: - Letters A-Z (also written KeyA-KeyZ) and digits 0-9 (also Digit0-Digit9). - Punctuation, either as the character or by name: `/Backquote, \/Backslash, [/BracketLeft, ]/BracketRight, ,/Comma, =/Equal, -/Minus, ./Period, '/Quote, ;/Semicolon, //Slash. - Backspace, CapsLock, Enter, Space, Tab, Delete, End, Home, Insert, PageDown, PageUp, PrintScreen, ScrollLock, NumLock, Escape (also Esc). - Arrows: ArrowUp, ArrowDown, ArrowLeft, ArrowRight (also Up, Down, Left, Right). - Function keys F1 through F24. - Numpad keys: Numpad0-Numpad9 (also Num0-Num9), NumpadAdd, NumpadSubtract, NumpadMultiply, NumpadDivide, NumpadDecimal, NumpadEnter, NumpadEqual (each also accepted with the Num prefix, e.g. NumAdd). - Media keys: AudioVolumeUp, AudioVolumeDown, AudioVolumeMute (also VolumeUp, VolumeDown, VolumeMute). Example import { MenuItem } from '@tauri-apps/api/menu'; await MenuItem.new({ text: 'Find', accelerator: 'CmdOrCtrl+F' }); await MenuItem.new({ text: 'Command palette', accelerator: 'CmdOrCtrl+Shift+P' }); await MenuItem.new({ text: 'Refresh', accelerator: 'F5' }); An accelerator that cannot be parsed is ignored and the item is created without a shortcut, so double-check the spelling of the modifiers and key. MenuItemOptions.accelerator packages/api/src/menu/menuItem.ts:64
action? (id: string) => void Specify a handler to be called when this menu item is activated. MenuItemOptions.action packages/api/src/menu/menuItem.ts:66
enabled? boolean Whether the new menu item is enabled or not. MenuItemOptions.enabled packages/api/src/menu/menuItem.ts:15
icon? MenuIcon Icon to be used for the new icon menu item. 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"] } - packages/api/src/menu/iconMenuItem.ts:144
id? string Specify an id to use for the new menu item. MenuItemOptions.id packages/api/src/menu/menuItem.ts:11
text string The text of the new menu item. MenuItemOptions.text packages/api/src/menu/menuItem.ts:13

Defined in: packages/api/src/menu/menuItem.ts:9

Options for creating a new menu item.

Property Type Description Defined in
accelerator? string Specify an accelerator (keyboard shortcut) for the new menu item, for example 'CmdOrCtrl+Shift+K'. The string is a list of zero or more modifiers followed by exactly one key, joined with +. Matching is case insensitive and spaces around each token are ignored, so 'CmdOrCtrl+Shift+K' and 'cmdorctrl + shift + k' are equivalent. All modifiers must come before the key. Accepted modifiers: - Shift - Control, Ctrl - Alt, Option - Command, Cmd, Super - CmdOrCtrl, CmdOrControl, CommandOrCtrl, CommandOrControl — Command on macOS and Control everywhere else, which is what you usually want for application shortcuts. Accepted keys: - Letters A-Z (also written KeyA-KeyZ) and digits 0-9 (also Digit0-Digit9). - Punctuation, either as the character or by name: `/Backquote, \/Backslash, [/BracketLeft, ]/BracketRight, ,/Comma, =/Equal, -/Minus, ./Period, '/Quote, ;/Semicolon, //Slash. - Backspace, CapsLock, Enter, Space, Tab, Delete, End, Home, Insert, PageDown, PageUp, PrintScreen, ScrollLock, NumLock, Escape (also Esc). - Arrows: ArrowUp, ArrowDown, ArrowLeft, ArrowRight (also Up, Down, Left, Right). - Function keys F1 through F24. - Numpad keys: Numpad0-Numpad9 (also Num0-Num9), NumpadAdd, NumpadSubtract, NumpadMultiply, NumpadDivide, NumpadDecimal, NumpadEnter, NumpadEqual (each also accepted with the Num prefix, e.g. NumAdd). - Media keys: AudioVolumeUp, AudioVolumeDown, AudioVolumeMute (also VolumeUp, VolumeDown, VolumeMute). Example import { MenuItem } from '@tauri-apps/api/menu'; await MenuItem.new({ text: 'Find', accelerator: 'CmdOrCtrl+F' }); await MenuItem.new({ text: 'Command palette', accelerator: 'CmdOrCtrl+Shift+P' }); await MenuItem.new({ text: 'Refresh', accelerator: 'F5' }); An accelerator that cannot be parsed is ignored and the item is created without a shortcut, so double-check the spelling of the modifiers and key. packages/api/src/menu/menuItem.ts:64
action? (id: string) => void Specify a handler to be called when this menu item is activated. packages/api/src/menu/menuItem.ts:66
enabled? boolean Whether the new menu item is enabled or not. packages/api/src/menu/menuItem.ts:15
id? string Specify an id to use for the new menu item. packages/api/src/menu/menuItem.ts:11
text string The text of the new menu item. packages/api/src/menu/menuItem.ts:13

Defined in: packages/api/src/menu/menu.ts:23

Options for creating a new menu.

Property Type Description Defined in
id? string Specify an id to use for the new menu. packages/api/src/menu/menu.ts:25
items? ( | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions)[] List of items to add to the new menu. packages/api/src/menu/menu.ts:27

Defined in: packages/api/src/menu/predefinedMenuItem.ts:84

Options for creating a new predefined menu item.

Property Type Description Defined in
item | "Separator" | "Copy" | "Cut" | "Paste" | "SelectAll" | "Undo" | "Redo" | "Minimize" | "Maximize" | "Fullscreen" | "Hide" | "HideOthers" | "ShowAll" | "CloseWindow" | "Quit" | "Services" | "BringAllToFront" | { About: | AboutMetadata | null; } The predefined item type. Each variant maps to a native menu item whose behavior is implemented by the operating system, so there is no action to handle. Variants that are unsupported on a platform still create an item, but it does nothing there. - Separator: a horizontal separator line. All platforms. - Copy, Cut, Paste, SelectAll: the standard clipboard and selection commands, applied to the focused text input. All platforms. - Undo, Redo: undo/redo in the focused text input. macOS only (Windows / Linux: unsupported). - Minimize: minimizes the focused window. Linux: unsupported. - Maximize: maximizes the focused window. Linux: unsupported. - Fullscreen: toggles fullscreen for the focused window. macOS only (Windows / Linux: unsupported). - Hide: hides the application. Linux: unsupported. - HideOthers: hides every other application. Linux: unsupported. - ShowAll: shows all hidden applications. macOS only (Windows / Linux: unsupported). - CloseWindow: closes the focused window. Linux: unsupported. - Quit: quits the application. Linux: unsupported. - Services: the macOS Services submenu. macOS only (Windows / Linux: unsupported). - BringAllToFront: brings all of the app’s windows to the front. macOS only (Windows / Linux: unsupported). - `{ About: AboutMetadata null }: opens an about dialog. All platforms; pass nullto use the values from yourtauri.conf.json, or see [AboutMetadata](/reference/javascript/api/namespacemenu/#aboutmetadata) for the per-field platform support. **Example** import { Menu, PredefinedMenuItem, Submenu } from ‘@tauri-apps/api/menu’; await using edit = await Submenu.new({ text: ‘Edit’, items: [ { item: ‘Undo’ }, { item: ‘Redo’ }, { item: ‘Separator’ }, { item: ‘Cut’ }, { item: ‘Copy’ }, { item: ‘Paste’ }, { item: ‘SelectAll’ } ] }); await using quit = await PredefinedMenuItem.new({ item: ‘Quit’, text: ‘Quit my app’ }); const menu = await Menu.new({ items: [edit, quit] });`
text? string The text of the new predefined menu item. Defaults to the platform’s own label for the chosen item, so only set it to override or localize that label. packages/api/src/menu/predefinedMenuItem.ts:91

type SubmenuOptions = Omit<MenuItemOptions, "accelerator" | "action"> & MenuOptions & {
icon?: MenuIcon;
};

Defined in: packages/api/src/menu/submenu.ts:50

Name Type Description Defined in
icon? MenuIcon Icon to be used for the submenu. Note: you may need the image-ico or image-png Cargo features to use this API. packages/api/src/menu/submenu.ts:56

© 2026 Tauri Contributors. CC-BY / MIT