---
title: "commandsReplaced(content:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/scene/commandsreplaced(content:)"
---

# commandsReplaced(content:)

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

## Declaration

```swift
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

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

## Discussion

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")                     }                 }             }         }     } }

## See Also

### Defining commands

- [commands(content:)](swiftui/scene/commands(content:).md)
- [commandsRemoved()](swiftui/scene/commandsremoved().md)
- [Commands](swiftui/commands.md)
- [CommandMenu](swiftui/commandmenu.md)
- [CommandGroup](swiftui/commandgroup.md)
- [CommandsBuilder](swiftui/commandsbuilder.md)
- [CommandGroupPlacement](swiftui/commandgroupplacement.md)
