Aller au contenu

menu

Ce contenu n’est pas encore disponible dans votre langue.

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.

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L17

A native Icon to be used for the menu item

Platform-specific:

  • Windows / Linux: Unsupported.

Add: "Add";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L19

An add item template image.

Advanced: "Advanced";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L21

Advanced preferences toolbar icon for the preferences window.

Bluetooth: "Bluetooth";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L23

A Bluetooth template image.

Bookmarks: "Bookmarks";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L25

Bookmarks image suitable for a template.

Caution: "Caution";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L27

A caution image.

ColorPanel: "ColorPanel";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L29

A color panel toolbar icon.

ColumnView: "ColumnView";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L31

A column view mode template image.

Computer: "Computer";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L33

A computer icon.

EnterFullScreen: "EnterFullScreen";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L35

An enter full-screen mode template image.

Everyone: "Everyone";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L37

Permissions for all users.

ExitFullScreen: "ExitFullScreen";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L39

An exit full-screen mode template image.

FlowView: "FlowView";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L41

A cover flow view mode template image.

Folder: "Folder";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L43

A folder image.

FolderBurnable: "FolderBurnable";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L45

A burnable folder icon.

FolderSmart: "FolderSmart";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L47

A smart folder icon.

FollowLinkFreestanding: "FollowLinkFreestanding";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L49

A link template image.

FontPanel: "FontPanel";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L51

A font panel toolbar icon.

GoLeft: "GoLeft";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L53

A go back template image.

GoRight: "GoRight";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L55

A go forward template image.

Home: "Home";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L57

Home image suitable for a template.

IChatTheater: "IChatTheater";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L59

An iChat Theater template image.

IconView: "IconView";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L61

An icon view mode template image.

Info: "Info";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L63

An information toolbar icon.

InvalidDataFreestanding: "InvalidDataFreestanding";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L65

A template image used to denote invalid data.

LeftFacingTriangle: "LeftFacingTriangle";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L67

A generic left-facing triangle template image.

ListView: "ListView";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L69

A list view mode template image.

LockLocked: "LockLocked";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L71

A locked padlock template image.

LockUnlocked: "LockUnlocked";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L73

An unlocked padlock template image.

MenuMixedState: "MenuMixedState";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L75

A horizontal dash, for use in menus.

MenuOnState: "MenuOnState";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L77

A check mark template image, for use in menus.

MobileMe: "MobileMe";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L79

A MobileMe icon.

MultipleDocuments: "MultipleDocuments";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L81

A drag image for multiple items.

Network: "Network";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L83

A network icon.

Path: "Path";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L85

A path button template image.

PreferencesGeneral: "PreferencesGeneral";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L87

General preferences toolbar icon for the preferences window.

QuickLook: "QuickLook";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L89

A Quick Look template image.

Refresh: "Refresh";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L93

A refresh template image.

RefreshFreestanding: "RefreshFreestanding";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L91

A refresh template image.

Remove: "Remove";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L95

A remove item template image.

RevealFreestanding: "RevealFreestanding";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L97

A reveal contents template image.

RightFacingTriangle: "RightFacingTriangle";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L99

A generic right-facing triangle template image.

Share: "Share";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L101

A share view template image.

Slideshow: "Slideshow";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L103

A slideshow template image.

SmartBadge: "SmartBadge";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L105

A badge for a smart item.

StatusAvailable: "StatusAvailable";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L107

Small green indicator, similar to iChat’s available image.

StatusNone: "StatusNone";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L109

Small clear indicator.

StatusPartiallyAvailable: "StatusPartiallyAvailable";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L111

Small yellow indicator, similar to iChat’s idle image.

StatusUnavailable: "StatusUnavailable";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L113

Small red indicator, similar to iChat’s unavailable image.

StopProgress: "StopProgress";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L117

A stop progress button template image.

StopProgressFreestanding: "StopProgressFreestanding";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L115

A stop progress template image.

TrashEmpty: "TrashEmpty";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L119

An image of the empty trash can.

TrashFull: "TrashFull";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L121

An image of the full trash can.

User: "User";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L123

Permissions for a single user.

UserAccounts: "UserAccounts";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L125

User account toolbar icon for the preferences window.

UserGroup: "UserGroup";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L127

Permissions for a group of users.

UserGuest: "UserGuest";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L129

Permissions for guests.

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/checkMenuItem.ts#L20

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;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/base.ts#L149

The id of this item.

string

MenuItemBase.id

get rid(): number;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L547

number

MenuItemBase.rid

asyncDispose: Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L568

Promise<void>

MenuItemBase.[asyncDispose]

close(): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L562

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

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/checkMenuItem.ts#L75

Returns whether this check menu item is checked or not.

Promise<boolean>

isEnabled(): Promise<boolean>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/checkMenuItem.ts#L48

Returns whether this check menu item is enabled or not.

Promise<boolean>

setAccelerator(accelerator): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/checkMenuItem.ts#L66

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): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/checkMenuItem.ts#L80

Sets whether this check menu item is checked or not.

Parameter Type
checked boolean

Promise<void>

setEnabled(enabled): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/checkMenuItem.ts#L53

Sets whether this check menu item is enabled or not.

Parameter Type
enabled boolean

Promise<void>

setText(text): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/checkMenuItem.ts#L39

Sets the text for this check menu item.

Parameter Type
text string

Promise<void>

text(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/checkMenuItem.ts#L34

Returns the text of this check menu item.

Promise<string>

static new(opts): Promise<CheckMenuItem>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/checkMenuItem.ts#L27

Create a new check menu item.

Parameter Type
opts CheckMenuItemOptions

Promise<CheckMenuItem>


Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L151

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

  • MenuItemBase

get id(): string;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/base.ts#L149

The id of this item.

string

MenuItemBase.id

get rid(): number;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L547

number

MenuItemBase.rid

asyncDispose: Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L568

Promise<void>

MenuItemBase.[asyncDispose]

close(): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L562

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

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L177

Returns whether this icon menu item is enabled or not.

Promise<boolean>

setAccelerator(accelerator): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L195

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): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L182

Sets whether this icon menu item is enabled or not.

Parameter Type
enabled boolean

Promise<void>

setIcon(icon): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L204

Sets an icon for this icon menu item

Parameter Type
icon MenuIcon | null

Promise<void>

setText(text): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L168

Sets the text for this icon menu item.

Parameter Type
text string

Promise<void>

text(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L163

Returns the text of this icon menu item.

Promise<string>

static new(opts): Promise<IconMenuItem>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L158

Create a new icon menu item.

Parameter Type
opts IconMenuItemOptions

Promise<IconMenuItem>


Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menu.ts#L48

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;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/base.ts#L149

The id of this item.

string

MenuItemBase.id

get rid(): number;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L547

number

MenuItemBase.rid

asyncDispose: Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L568

Promise<void>

MenuItemBase.[asyncDispose]

append<T>(items): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menu.ts#L117

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

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L562

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): Promise<
| Submenu
| MenuItem
| PredefinedMenuItem
| CheckMenuItem
| IconMenuItem
| null>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menu.ts#L240

Retrieves the menu item matching the given identifier.

Parameter Type
id string

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

insert<T>(items, position): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menu.ts#L175

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)[]>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menu.ts#L228

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

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

popup(at?, window?): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menu.ts#L284

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.

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>

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

prepend<T>(items): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menu.ts#L146

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): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menu.ts#L199

Remove a menu item from this menu.

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

Promise<void>

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

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menu.ts#L210

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

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menu.ts#L317

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.

Promise<Menu | null>

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

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

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

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menu.ts#L343

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

import { Menu } from '@tauri-apps/api/menu';
import { getCurrentWindow } from '@tauri-apps/api/window';
const menu = await Menu.default();
await menu.setAsWindowMenu(getCurrentWindow());

static default(): Promise<Menu>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menu.ts#L104

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.

Promise<Menu>

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

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

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menu.ts#L75

Create a new menu.

Parameter Type
opts? MenuOptions

Promise<Menu>

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

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L70

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

  • MenuItemBase

get id(): string;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/base.ts#L149

The id of this item.

string

MenuItemBase.id

get rid(): number;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L547

number

MenuItemBase.rid

asyncDispose: Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L568

Promise<void>

MenuItemBase.[asyncDispose]

close(): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L562

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

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L96

Returns whether this menu item is enabled or not.

Promise<boolean>

setAccelerator(accelerator): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L119

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

See MenuItemOptions.accelerator for the accepted format.

Parameter Type
accelerator string | null

Promise<void>

await item.setAccelerator('CmdOrCtrl+Shift+K');

setEnabled(enabled): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L101

Sets whether this menu item is enabled or not.

Parameter Type
enabled boolean

Promise<void>

setText(text): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L87

Sets the text for this menu item.

Parameter Type
text string

Promise<void>

text(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L82

Returns the text of this menu item.

Promise<string>

static new(opts): Promise<MenuItem>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L77

Create a new menu item.

Parameter Type
opts MenuItemOptions

Promise<MenuItem>


Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/predefinedMenuItem.ts#L167

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

  • MenuItemBase

get id(): string;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/base.ts#L149

The id of this item.

string

MenuItemBase.id

get rid(): number;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L547

number

MenuItemBase.rid

asyncDispose: Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L568

Promise<void>

MenuItemBase.[asyncDispose]

close(): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L562

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): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/predefinedMenuItem.ts#L196

Sets the text for this predefined menu item.

Parameter Type
text string

Promise<void>

text(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/predefinedMenuItem.ts#L191

Returns the text of this predefined menu item.

Promise<string>

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

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/predefinedMenuItem.ts#L182

Create a new predefined menu item.

Parameter Type
opts? PredefinedMenuItemOptions

Promise<PredefinedMenuItem>

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

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/submenu.ts#L60

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

  • MenuItemBase

get id(): string;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/base.ts#L149

The id of this item.

string

MenuItemBase.id

get rid(): number;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L547

number

MenuItemBase.rid

asyncDispose: Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L568

Promise<void>

MenuItemBase.[asyncDispose]

append<T>(items): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/submenu.ts#L106

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

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L562

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): Promise<
| Submenu
| MenuItem
| PredefinedMenuItem
| CheckMenuItem
| IconMenuItem
| null>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/submenu.ts#L229

Retrieves the menu item matching the given identifier.

Parameter Type
id string

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

insert<T>(items, position): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/submenu.ts#L164

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

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/submenu.ts#L86

Returns whether this submenu is enabled or not.

Promise<boolean>

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

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/submenu.ts#L217

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

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

popup(at?, window?): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/submenu.ts#L251

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>(items): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/submenu.ts#L135

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): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/submenu.ts#L188

Remove a menu item from this submenu.

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

Promise<void>

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

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/submenu.ts#L199

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

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/submenu.ts#L291

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

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/submenu.ts#L273

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): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/submenu.ts#L91

Sets whether this submenu is enabled or not.

Parameter Type
enabled boolean

Promise<void>

setIcon(icon): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/submenu.ts#L298

Sets an icon for this submenu

Parameter Type
icon MenuIcon | null

Promise<void>

setText(text): Promise<void>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/submenu.ts#L77

Sets the text for this submenu.

Parameter Type
text string

Promise<void>

text(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/submenu.ts#L72

Returns the text of this submenu.

Promise<string>

static new(opts): Promise<Submenu>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/submenu.ts#L67

Create a new submenu.

Parameter Type
opts SubmenuOptions

Promise<Submenu>

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/predefinedMenuItem.ts#L10

A metadata for the about predefined menu item.

Property Type Description Defined in
authors? string[] The authors of the application. Platform-specific - macOS: Unsupported. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/predefinedMenuItem.ts#L30
comments? string Application comments. Platform-specific - macOS: Unsupported. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/predefinedMenuItem.ts#L38
copyright? string The copyright of the application. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/predefinedMenuItem.ts#L40
credits? string The credits. Platform-specific - Windows / Linux: Unsupported. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/predefinedMenuItem.ts#L72
icon? JsImage The application icon. Platform-specific - Windows: Unsupported. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/predefinedMenuItem.ts#L80
license? string The license of the application. Platform-specific - macOS: Unsupported. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/predefinedMenuItem.ts#L48
name? string Sets the application name. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/predefinedMenuItem.ts#L12
shortVersion? string The short version, e.g. “1.0”. Platform-specific - Windows / Linux: Appended to the end of version in parentheses. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/predefinedMenuItem.ts#L22
version? string The application version. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/predefinedMenuItem.ts#L14
website? string The application website. Platform-specific - macOS: Unsupported. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/predefinedMenuItem.ts#L56
websiteLabel? string The website label. Platform-specific - macOS: Unsupported. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/predefinedMenuItem.ts#L64

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/checkMenuItem.ts#L10

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 Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L64
action? (id) => void Specify a handler to be called when this menu item is activated. MenuItemOptions.action Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L66
checked? boolean Whether the new check menu item is enabled or not. - Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/checkMenuItem.ts#L12
enabled? boolean Whether the new menu item is enabled or not. MenuItemOptions.enabled Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L15
id? string Specify an id to use for the new menu item. MenuItemOptions.id Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L11
text string The text of the new menu item. MenuItemOptions.text Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L13

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L133

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 Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L64
action? (id) => void Specify a handler to be called when this menu item is activated. MenuItemOptions.action Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L66
enabled? boolean Whether the new menu item is enabled or not. MenuItemOptions.enabled Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L15
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"] } - Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L144
id? string Specify an id to use for the new menu item. MenuItemOptions.id Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L11
text string The text of the new menu item. MenuItemOptions.text Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L13

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L9

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. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L64
action? (id) => void Specify a handler to be called when this menu item is activated. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L66
enabled? boolean Whether the new menu item is enabled or not. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L15
id? string Specify an id to use for the new menu item. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L11
text string The text of the new menu item. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L13

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menu.ts#L23

Options for creating a new menu.

Property Type Description Defined in
id? string Specify an id to use for the new menu. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menu.ts#L25
items? ( | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions)[] List of items to add to the new menu. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menu.ts#L27

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/predefinedMenuItem.ts#L84

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’; const edit = await Submenu.new({ text: ‘Edit’, items: [ { item: ‘Undo’ }, { item: ‘Redo’ }, { item: ‘Separator’ }, { item: ‘Cut’ }, { item: ‘Copy’ }, { item: ‘Paste’ }, { item: ‘SelectAll’ } ] }); const 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. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/predefinedMenuItem.ts#L91

type SubmenuOptions = Omit<MenuItemOptions, "accelerator" | "action"> & MenuOptions & object;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/submenu.ts#L50

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. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/submenu.ts#L56

© 2026 Tauri Contributors. CC-BY / MIT