<!--
{
  "availability" : [
    "macOS: 10.15.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/onCopyCommand(perform:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE13onCopyCommand7performQrSaySo14NSItemProviderCGycSg_tF"
  },
  "title" : "onCopyCommand(perform:)"
}
-->

# onCopyCommand(perform:)

Adds an action to perform in response to the system’s Copy command.

```
nonisolated func onCopyCommand(perform payloadAction: (() -> [NSItemProvider])?) -> some View
```

## Parameters

`payloadAction`

An action closure returning the
<doc://com.apple.documentation/documentation/Foundation/NSItemProvider> items that
should be copied to the Clipboard when the Copy command is
triggered. If `action` is `nil`, the Copy command is considered
disabled.

## Return Value

A view that triggers `action` when a system Copy command
occurs.

---

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)