Skip to main content
Версия: Next Version 🚧


It is possible to add an application menu to Wails projects. This is achieved by defining a Menu struct and setting it in the Menu application config, or by calling the runtime method MenuSetApplicationMenu.

An example of how to create a menu:

app := NewApp()

AppMenu := menu.NewMenu()
FileMenu := AppMenu.AddSubmenu("File")
FileMenu.AddText("&Open", keys.CmdOrCtrl("o"), openFile)
FileMenu.AddText("Quit", keys.CmdOrCtrl("q"), func(_ *menu.CallbackData) {

if runtime.GOOS == "darwin" {
AppMenu.Append(menu.EditMenu()) // on macos platform, we should append EditMenu to enable Cmd+C,Cmd+V,Cmd+Z... shortcut

err := wails.Run(&options.App{
Title: "Menus Demo",
Width: 800,
Height: 600,
Menu: AppMenu, // reference the menu above
Bind: []interface{}{
// ...

It is also possible to dynamically update the menu, by updating the menu struct and calling MenuUpdateApplicationMenu.

The example above uses helper methods, however it's possible to build the menu structs manually.

A Menu is a collection of MenuItems:

type Menu struct {
Items []*MenuItem

For the Application menu, each MenuItem represents a single menu such as "Edit".

A simple helper method is provided for building menus:

func NewMenuFromItems(first *MenuItem, rest ...*MenuItem) *Menu

This makes the layout of the code more like that of a menu without the need to add the menu items manually after creating them. Alternatively, you can just create the menu items and add them to the menu manually.

A MenuItem represents an item within a Menu.

// MenuItem represents a menu item contained in a menu
type MenuItem struct {
Label string
Role Role
Accelerator *keys.Accelerator
Type Type
Disabled bool
Hidden bool
Checked bool
SubMenu *Menu
Click Callback
LabelstringThe menu text
Accelerator*keys.AcceleratorKey binding for this menu item
TypeTypeType of MenuItem
DisabledboolDisables the menu item
HiddenboolHides this menu item
CheckedboolAdds check to item (Checkbox & Radio types)
SubMenu*MenuSets the submenu
ClickCallbackCallback function when menu clicked
RolestringDefines a role for this menu item. Mac only for now.


Accelerators (sometimes called keyboard shortcuts) define a binding between a keystroke and a menu item. Wails defines an Accelerator as a combination or key + Modifier. They are available in the "" package.


    // Defines cmd+o on Mac and ctrl-o on Window/Linux
myShortcut := keys.CmdOrCtrl("o")

Keys are any single character on a keyboard with the exception of +, which is defined as plus. Some keys cannot be represented as characters so there are a set of named characters that may be used:

page upf14f39
page downf15f30

Wails also supports parsing accelerators using the same syntax as Electron. This is useful for storing accelerators in config files.


    // Defines cmd+o on Mac and ctrl-o on Window/Linux
myShortcut, err := keys.Parse("Ctrl+Option+A")


The following modifiers are keys that may be used in combination with the accelerator key:

const (
// CmdOrCtrlKey represents Command on Mac and Control on other platforms
CmdOrCtrlKey Modifier = "cmdorctrl"
// OptionOrAltKey represents Option on Mac and Alt on other platforms
OptionOrAltKey Modifier = "optionoralt"
// ShiftKey represents the shift key on all systems
ShiftKey Modifier = "shift"
// ControlKey represents the control key on all systems
ControlKey Modifier = "ctrl"

A number of helper methods are available to create Accelerators using modifiers:

func CmdOrCtrl(key string) *Accelerator
func OptionOrAlt(key string) *Accelerator
func Shift(key string) *Accelerator
func Control(key string) *Accelerator

Modifiers can be combined using keys.Combo(key string, modifier1 Modifier, modifier2 Modifier, rest ...Modifier):

    // Defines "Ctrl+Option+A" on Mac and "Ctrl+Alt+A" on Window/Linux
myShortcut := keys.Combo("a", ControlKey, OptionOrAltKey)


Each menu item must have a type and there are 5 types available:

const (
TextType Type = "Text"
SeparatorType Type = "Separator"
SubmenuType Type = "Submenu"
CheckboxType Type = "Checkbox"
RadioType Type = "Radio"

For convenience, helper methods are provided to quickly create a menu item:

func Text(label string, accelerator *keys.Accelerator, click Callback) *MenuItem
func Separator() *MenuItem
func Radio(label string, selected bool, accelerator *keys.Accelerator, click Callback) *MenuItem
func Checkbox(label string, checked bool, accelerator *keys.Accelerator, click Callback) *MenuItem
func SubMenu(label string, menu *Menu) *Menu

You can also create menu items directly on a menu by using the "Add" helpers:

func (m *Menu) AddText(label string, accelerator *keys.Accelerator, click Callback) *MenuItem
func (m *Menu) AddSeparator() *MenuItem
func (m *Menu) AddRadio(label string, selected bool, accelerator *keys.Accelerator, click Callback) *MenuItem
func (m *Menu) AddCheckbox(label string, checked bool, accelerator *keys.Accelerator, click Callback) *MenuItem
func (m *Menu) AddSubMenu(label string, menu *Menu) *MenuI

A note on radio groups: A radio group is defined as a number of radio menu items that are next to each other in the menu. This means that you do not need to group items together as it is automatic. However, that also means you cannot have 2 radio groups next to each other - there must be a non-radio item between them.


Each menu item may have a callback that is executed when the item is clicked:

type Callback func(*CallbackData)

type CallbackData struct {
MenuItem *MenuItem

The function is given a CallbackData struct which indicates which menu item triggered the callback. This is useful when using radio groups that may share a callback.



Roles are currently supported on Mac only.

A menu item may have a role, which is essentially a pre-defined menu item. We currently support the following roles:

AppMenuRoleThe standard Mac application menu. Can be created using menu.AppMenu()
EditMenuRoleThe standard Mac edit menu. Can be created using menu.EditMenu()