<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Scene/commandsReplaced(content:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI5ScenePAAE16commandsReplaced7contentQrqd__yXE_tAA8CommandsRd__lF"
  },
  "title" : "commandsReplaced(content:)"
}
-->

# commandsReplaced(content:)

Replaces all commands defined by the modified scene with the commands
from the builder.

```
nonisolated func commandsReplaced<Content>(@ContentBuilder content: () -> Content) -> some Scene where Content : Commands
```

## Parameters

`content`

A `Commands` builder whose output will be used to replace
the commands normally provided by the modified scene.

## Return Value

A scene that replaces any commands defined by its children
with alternative content.

## Discussion

`WindowGroup`, `Window`, and other scene types all have an associated
set of commands that they include by default. Apply this modifier to a
scene to replace those commands with the output from the given builder.

For example, the following code adds a scene for showing the contents of
the pasteboard in a dedicated window. We replace the scene’s default
Window > Clipboard menu command with a custom Edit > Show Clipboard
command that we place next to the other pasteboard commands.

```
@main
struct Example: App {
    @Environment(\.openWindow) var openWindow

    var body: some Scene {
        ...

        Window("Clipboard", id: "clipboard") {
            ClipboardContentView()
        }
        .commandsReplaced {
            CommandGroup(after: .pasteboard) {
                Section {
                    Button("Show Clipboard") {
                        openWindow(id: "clipboard")
                    }
                }
            }
        }
    }
}
```

---

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)