<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Commands",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI8CommandsP"
  },
  "title" : "Commands"
}
-->

# Commands

Conforming types represent a group of related commands that can be exposed
to the user via the main menu on macOS and key commands on iOS.

```
@MainActor @preconcurrency protocol Commands
```

## Overview

A type conforming to this protocol inherits `@preconcurrency @MainActor`
isolation from the protocol if the conformance is included in the type’s
base declaration:

```
struct MyCustomType: Transition {
    // `@preconcurrency @MainActor` isolation by default
}
```

Isolation to the main actor is the default, but it’s not required. Declare
the conformance in an extension to opt out of main actor isolation:

```
extension MyCustomType: Transition {
    // `nonisolated` by default
}
```

## Topics

### Implementing commands

[`body`](/documentation/SwiftUI/Commands/body-swift.property)

The contents of the command hierarchy.

[`Body`](/documentation/SwiftUI/Commands/Body-swift.associatedtype)

The type of commands that represents the body of this command hierarchy.

## Relationships

### Conforming Types

[`SidebarCommands`](/documentation/SwiftUI/SidebarCommands)

[`CommandMenu`](/documentation/SwiftUI/CommandMenu)

[`TupleContent`](/documentation/SwiftUI/TupleContent)

[`EmptyView`](/documentation/SwiftUI/EmptyView)

[`TextFormattingCommands`](/documentation/SwiftUI/TextFormattingCommands)

[`ToolbarCommands`](/documentation/SwiftUI/ToolbarCommands)

[`TextEditingCommands`](/documentation/SwiftUI/TextEditingCommands)

[`CommandGroup`](/documentation/SwiftUI/CommandGroup)

[`ImportFromDevicesCommands`](/documentation/SwiftUI/ImportFromDevicesCommands)

[`EmptyCommands`](/documentation/SwiftUI/EmptyCommands)

[`Group`](/documentation/SwiftUI/Group)

[`InspectorCommands`](/documentation/SwiftUI/InspectorCommands)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)