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.
Remarks
Section titled “Remarks”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.
Enumerations
Section titled “Enumerations”NativeIcon
Section titled “NativeIcon”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.
Enumeration Members
Section titled “Enumeration Members”Add: "Add";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L19
An add item template image.
Advanced
Section titled “Advanced”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
Section titled “Bluetooth”Bluetooth: "Bluetooth";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L23
A Bluetooth template image.
Bookmarks
Section titled “Bookmarks”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
Section titled “Caution”Caution: "Caution";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L27
A caution image.
ColorPanel
Section titled “ColorPanel”ColorPanel: "ColorPanel";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L29
A color panel toolbar icon.
ColumnView
Section titled “ColumnView”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
Section titled “Computer”Computer: "Computer";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L33
A computer icon.
EnterFullScreen
Section titled “EnterFullScreen”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
Section titled “Everyone”Everyone: "Everyone";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L37
Permissions for all users.
ExitFullScreen
Section titled “ExitFullScreen”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
Section titled “FlowView”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
Section titled “Folder”Folder: "Folder";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L43
A folder image.
FolderBurnable
Section titled “FolderBurnable”FolderBurnable: "FolderBurnable";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L45
A burnable folder icon.
FolderSmart
Section titled “FolderSmart”FolderSmart: "FolderSmart";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L47
A smart folder icon.
FollowLinkFreestanding
Section titled “FollowLinkFreestanding”FollowLinkFreestanding: "FollowLinkFreestanding";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L49
A link template image.
FontPanel
Section titled “FontPanel”FontPanel: "FontPanel";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L51
A font panel toolbar icon.
GoLeft
Section titled “GoLeft”GoLeft: "GoLeft";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L53
A go back template image.
GoRight
Section titled “GoRight”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
Section titled “IChatTheater”IChatTheater: "IChatTheater";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L59
An iChat Theater template image.
IconView
Section titled “IconView”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
Section titled “InvalidDataFreestanding”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
Section titled “LeftFacingTriangle”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
Section titled “ListView”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
Section titled “LockLocked”LockLocked: "LockLocked";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L71
A locked padlock template image.
LockUnlocked
Section titled “LockUnlocked”LockUnlocked: "LockUnlocked";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L73
An unlocked padlock template image.
MenuMixedState
Section titled “MenuMixedState”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
Section titled “MenuOnState”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
Section titled “MobileMe”MobileMe: "MobileMe";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L79
A MobileMe icon.
MultipleDocuments
Section titled “MultipleDocuments”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
Section titled “Network”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
Section titled “PreferencesGeneral”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
Section titled “QuickLook”QuickLook: "QuickLook";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L89
A Quick Look template image.
Refresh
Section titled “Refresh”Refresh: "Refresh";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L93
A refresh template image.
RefreshFreestanding
Section titled “RefreshFreestanding”RefreshFreestanding: "RefreshFreestanding";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L91
A refresh template image.
Remove
Section titled “Remove”Remove: "Remove";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L95
A remove item template image.
RevealFreestanding
Section titled “RevealFreestanding”RevealFreestanding: "RevealFreestanding";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L97
A reveal contents template image.
RightFacingTriangle
Section titled “RightFacingTriangle”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
Section titled “Slideshow”Slideshow: "Slideshow";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L103
A slideshow template image.
SmartBadge
Section titled “SmartBadge”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
Section titled “StatusAvailable”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
Section titled “StatusNone”StatusNone: "StatusNone";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L109
Small clear indicator.
StatusPartiallyAvailable
Section titled “StatusPartiallyAvailable”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
Section titled “StatusUnavailable”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
Section titled “StopProgress”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
Section titled “StopProgressFreestanding”StopProgressFreestanding: "StopProgressFreestanding";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L115
A stop progress template image.
TrashEmpty
Section titled “TrashEmpty”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
Section titled “TrashFull”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
Section titled “UserAccounts”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
Section titled “UserGroup”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
Section titled “UserGuest”UserGuest: "UserGuest";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L129
Permissions for guests.
Classes
Section titled “Classes”CheckMenuItem
Section titled “CheckMenuItem”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.
Extends
Section titled “Extends”MenuItemBase
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get id(): string;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/base.ts#L149
The id of this item.
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”MenuItemBase.idGet Signature
Section titled “Get Signature”get rid(): number;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L547
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”MenuItemBase.ridMethods
Section titled “Methods”[asyncDispose]()
Section titled “[asyncDispose]()”asyncDispose: Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L568
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”MenuItemBase.[asyncDispose]close()
Section titled “close()”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.
Returns
Section titled “Returns”Promise<void>
Remarks
Section titled “Remarks”Uses the core:resources:allow-close permission, which is part of
the core:resources:default permission set enabled by default.
Inherited from
Section titled “Inherited from”MenuItemBase.closeisChecked()
Section titled “isChecked()”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.
Returns
Section titled “Returns”Promise<boolean>
isEnabled()
Section titled “isEnabled()”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.
Returns
Section titled “Returns”Promise<boolean>
setAccelerator()
Section titled “setAccelerator()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
accelerator |
string | null |
Returns
Section titled “Returns”Promise<void>
setChecked()
Section titled “setChecked()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
checked |
boolean |
Returns
Section titled “Returns”Promise<void>
setEnabled()
Section titled “setEnabled()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
enabled |
boolean |
Returns
Section titled “Returns”Promise<void>
setText()
Section titled “setText()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
text |
string |
Returns
Section titled “Returns”Promise<void>
text()
Section titled “text()”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.
Returns
Section titled “Returns”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
opts |
CheckMenuItemOptions |
Returns
Section titled “Returns”IconMenuItem
Section titled “IconMenuItem”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.
Extends
Section titled “Extends”MenuItemBase
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get id(): string;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/base.ts#L149
The id of this item.
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”MenuItemBase.idGet Signature
Section titled “Get Signature”get rid(): number;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L547
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”MenuItemBase.ridMethods
Section titled “Methods”[asyncDispose]()
Section titled “[asyncDispose]()”asyncDispose: Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L568
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”MenuItemBase.[asyncDispose]close()
Section titled “close()”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.
Returns
Section titled “Returns”Promise<void>
Remarks
Section titled “Remarks”Uses the core:resources:allow-close permission, which is part of
the core:resources:default permission set enabled by default.
Inherited from
Section titled “Inherited from”MenuItemBase.closeisEnabled()
Section titled “isEnabled()”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.
Returns
Section titled “Returns”Promise<boolean>
setAccelerator()
Section titled “setAccelerator()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
accelerator |
string | null |
Returns
Section titled “Returns”Promise<void>
setEnabled()
Section titled “setEnabled()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
enabled |
boolean |
Returns
Section titled “Returns”Promise<void>
setIcon()
Section titled “setIcon()”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
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
icon |
MenuIcon | null |
Returns
Section titled “Returns”Promise<void>
setText()
Section titled “setText()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
text |
string |
Returns
Section titled “Returns”Promise<void>
text()
Section titled “text()”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.
Returns
Section titled “Returns”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
opts |
IconMenuItemOptions |
Returns
Section titled “Returns”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:
Extends
Section titled “Extends”MenuItemBase
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get id(): string;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/base.ts#L149
The id of this item.
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”MenuItemBase.idGet Signature
Section titled “Get Signature”get rid(): number;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L547
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”MenuItemBase.ridMethods
Section titled “Methods”[asyncDispose]()
Section titled “[asyncDispose]()”asyncDispose: Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L568
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”MenuItemBase.[asyncDispose]append()
Section titled “append()”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 Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T extends | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
items |
T | T[] |
Returns
Section titled “Returns”Promise<void>
close()
Section titled “close()”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.
Returns
Section titled “Returns”Promise<void>
Remarks
Section titled “Remarks”Uses the core:resources:allow-close permission, which is part of
the core:resources:default permission set enabled by default.
Inherited from
Section titled “Inherited from”MenuItemBase.closeget(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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id |
string |
Returns
Section titled “Returns”Promise<
| Submenu
| MenuItem
| PredefinedMenuItem
| CheckMenuItem
| IconMenuItem
| null>
insert()
Section titled “insert()”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 Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T extends | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
items |
T | T[] |
position |
number |
Returns
Section titled “Returns”Promise<void>
items()
Section titled “items()”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.
Returns
Section titled “Returns”Promise<(
| Submenu
| MenuItem
| PredefinedMenuItem
| CheckMenuItem
| IconMenuItem)[]>
popup()
Section titled “popup()”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.
Parameters
Section titled “Parameters”| 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. |
Returns
Section titled “Returns”Promise<void>
Example
Section titled “Example”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()
Section titled “prepend()”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 Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T extends | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
items |
T | T[] |
Returns
Section titled “Returns”Promise<void>
remove()
Section titled “remove()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
item |
| Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem |
Returns
Section titled “Returns”Promise<void>
removeAt()
Section titled “removeAt()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
position |
number |
Returns
Section titled “Returns”Promise<
| Submenu
| MenuItem
| PredefinedMenuItem
| CheckMenuItem
| IconMenuItem
| null>
setAsAppMenu()
Section titled “setAsAppMenu()”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.
Returns
Section titled “Returns”The menu that was set before this call, or null if there was none.
Example
Section titled “Example”import { Menu } from '@tauri-apps/api/menu';
const menu = await Menu.default();const previous = await menu.setAsAppMenu();await previous?.close();setAsWindowMenu()
Section titled “setAsWindowMenu()”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.setAsAppMenuinstead.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
window? |
Window |
The window to set the menu on. Defaults to the current window. |
Returns
Section titled “Returns”The menu that was set on that window before this call, or null if there was none.
Example
Section titled “Example”import { Menu } from '@tauri-apps/api/menu';import { getCurrentWindow } from '@tauri-apps/api/window';
const menu = await Menu.default();await menu.setAsWindowMenu(getCurrentWindow());default()
Section titled “default()”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
Viewsubmenu with the fullscreen item. - Windows: a
Filesubmenu with close window and quit; the about item lives inHelp. - Linux: no
Filesubmenu; the about item lives inHelp.
Useful as a starting point you then extend with Menu.append,
Menu.insert or Menu.prepend.
Returns
Section titled “Returns”Example
Section titled “Example”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
opts? |
MenuOptions |
Returns
Section titled “Returns”Example
Section titled “Example”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' } ] }) ]});MenuItem
Section titled “MenuItem”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.
Extends
Section titled “Extends”MenuItemBase
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get id(): string;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/base.ts#L149
The id of this item.
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”MenuItemBase.idGet Signature
Section titled “Get Signature”get rid(): number;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L547
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”MenuItemBase.ridMethods
Section titled “Methods”[asyncDispose]()
Section titled “[asyncDispose]()”asyncDispose: Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L568
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”MenuItemBase.[asyncDispose]close()
Section titled “close()”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.
Returns
Section titled “Returns”Promise<void>
Remarks
Section titled “Remarks”Uses the core:resources:allow-close permission, which is part of
the core:resources:default permission set enabled by default.
Inherited from
Section titled “Inherited from”MenuItemBase.closeisEnabled()
Section titled “isEnabled()”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.
Returns
Section titled “Returns”Promise<boolean>
setAccelerator()
Section titled “setAccelerator()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
accelerator |
string | null |
Returns
Section titled “Returns”Promise<void>
Example
Section titled “Example”await item.setAccelerator('CmdOrCtrl+Shift+K');setEnabled()
Section titled “setEnabled()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
enabled |
boolean |
Returns
Section titled “Returns”Promise<void>
setText()
Section titled “setText()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
text |
string |
Returns
Section titled “Returns”Promise<void>
text()
Section titled “text()”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.
Returns
Section titled “Returns”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
opts |
MenuItemOptions |
Returns
Section titled “Returns”PredefinedMenuItem
Section titled “PredefinedMenuItem”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.
Extends
Section titled “Extends”MenuItemBase
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get id(): string;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/base.ts#L149
The id of this item.
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”MenuItemBase.idGet Signature
Section titled “Get Signature”get rid(): number;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L547
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”MenuItemBase.ridMethods
Section titled “Methods”[asyncDispose]()
Section titled “[asyncDispose]()”asyncDispose: Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L568
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”MenuItemBase.[asyncDispose]close()
Section titled “close()”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.
Returns
Section titled “Returns”Promise<void>
Remarks
Section titled “Remarks”Uses the core:resources:allow-close permission, which is part of
the core:resources:default permission set enabled by default.
Inherited from
Section titled “Inherited from”MenuItemBase.closesetText()
Section titled “setText()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
text |
string |
Returns
Section titled “Returns”Promise<void>
text()
Section titled “text()”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.
Returns
Section titled “Returns”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
opts? |
PredefinedMenuItemOptions |
Returns
Section titled “Returns”Example
Section titled “Example”import { PredefinedMenuItem } from '@tauri-apps/api/menu';const separator = await PredefinedMenuItem.new({ item: 'Separator' });Submenu
Section titled “Submenu”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.
Extends
Section titled “Extends”MenuItemBase
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get id(): string;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/base.ts#L149
The id of this item.
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”MenuItemBase.idGet Signature
Section titled “Get Signature”get rid(): number;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L547
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”MenuItemBase.ridMethods
Section titled “Methods”[asyncDispose]()
Section titled “[asyncDispose]()”asyncDispose: Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L568
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”MenuItemBase.[asyncDispose]append()
Section titled “append()”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 Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T extends | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
items |
T | T[] |
Returns
Section titled “Returns”Promise<void>
close()
Section titled “close()”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.
Returns
Section titled “Returns”Promise<void>
Remarks
Section titled “Remarks”Uses the core:resources:allow-close permission, which is part of
the core:resources:default permission set enabled by default.
Inherited from
Section titled “Inherited from”MenuItemBase.closeget(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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id |
string |
Returns
Section titled “Returns”Promise<
| Submenu
| MenuItem
| PredefinedMenuItem
| CheckMenuItem
| IconMenuItem
| null>
insert()
Section titled “insert()”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 Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T extends | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
items |
T | T[] |
position |
number |
Returns
Section titled “Returns”Promise<void>
isEnabled()
Section titled “isEnabled()”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.
Returns
Section titled “Returns”Promise<boolean>
items()
Section titled “items()”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.
Returns
Section titled “Returns”Promise<(
| Submenu
| MenuItem
| PredefinedMenuItem
| CheckMenuItem
| IconMenuItem)[]>
popup()
Section titled “popup()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
at? |
| PhysicalPosition | LogicalPosition |
window? |
Window |
Returns
Section titled “Returns”Promise<void>
prepend()
Section titled “prepend()”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 Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T extends | Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
items |
T | T[] |
Returns
Section titled “Returns”Promise<void>
remove()
Section titled “remove()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
item |
| Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem |
Returns
Section titled “Returns”Promise<void>
removeAt()
Section titled “removeAt()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
position |
number |
Returns
Section titled “Returns”Promise<
| Submenu
| MenuItem
| PredefinedMenuItem
| CheckMenuItem
| IconMenuItem
| null>
setAsHelpMenuForNSApp()
Section titled “setAsHelpMenuForNSApp()”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.
Returns
Section titled “Returns”Promise<void>
setAsWindowsMenuForNSApp()
Section titled “setAsWindowsMenuForNSApp()”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.
Returns
Section titled “Returns”Promise<void>
setEnabled()
Section titled “setEnabled()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
enabled |
boolean |
Returns
Section titled “Returns”Promise<void>
setIcon()
Section titled “setIcon()”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
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
icon |
MenuIcon | null |
Returns
Section titled “Returns”Promise<void>
setText()
Section titled “setText()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
text |
string |
Returns
Section titled “Returns”Promise<void>
text()
Section titled “text()”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.
Returns
Section titled “Returns”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
opts |
SubmenuOptions |
Returns
Section titled “Returns”Interfaces
Section titled “Interfaces”AboutMetadata
Section titled “AboutMetadata”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/predefinedMenuItem.ts#L10
A metadata for the about predefined menu item.
Properties
Section titled “Properties”CheckMenuItemOptions
Section titled “CheckMenuItemOptions”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/checkMenuItem.ts#L10
Options for creating a new check menu item.
Extends
Section titled “Extends”Properties
Section titled “Properties”| 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 |
IconMenuItemOptions
Section titled “IconMenuItemOptions”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/iconMenuItem.ts#L133
Options for creating a new icon menu item.
Extends
Section titled “Extends”Properties
Section titled “Properties”| 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 |
MenuItemOptions
Section titled “MenuItemOptions”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menuItem.ts#L9
Options for creating a new menu item.
Extended by
Section titled “Extended by”Properties
Section titled “Properties”| 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 |
MenuOptions
Section titled “MenuOptions”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/menu.ts#L23
Options for creating a new menu.
Properties
Section titled “Properties”| 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 |
PredefinedMenuItemOptions
Section titled “PredefinedMenuItemOptions”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/predefinedMenuItem.ts#L84
Options for creating a new predefined menu item.
Properties
Section titled “Properties”| 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 Aliases
Section titled “Type Aliases”SubmenuOptions
Section titled “SubmenuOptions”type SubmenuOptions = Omit<MenuItemOptions, "accelerator" | "action"> & MenuOptions & object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/menu/submenu.ts#L50
Type Declaration
Section titled “Type Declaration”| 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