Menus and commands
Provide space-efficient, context-dependent access to commands and controls.
Overview
Use a menu to provide people with easy access to common commands. You can add items to a macOS or iPadOS app’s menu bar using the commands(content:) scene modifier, or create context menus that people reveal near their current task using the contextMenu(menuItems:) view modifier.
[Image]
Create submenus by nesting Menu instances inside others. Use a Divider view to create a separator between menu elements.
For design guidance, see Menus in the Human Interface Guidelines.
Topics
Building a menu bar
Creating a menu
Creating context menus
contextMenu(menuItems:)contextMenu(menuItems:preview:)contextMenu(forSelectionType:menu:primaryAction:)
Defining commands
commands(content:)commandsRemoved()commandsReplaced(content:)CommandsCommandMenuCommandGroupCommandsBuilderCommandGroupPlacement
Getting built-in command groups
SidebarCommandsTextEditingCommandsTextFormattingCommandsToolbarCommandsImportFromDevicesCommandsInspectorCommandsEmptyCommands