<!--
{
  "availability" : [
    "macOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/onPasteCommand(of:perform:)-9s227",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE14onPasteCommand2of7performQrSay22UniformTypeIdentifiers6UTTypeVG_ySaySo14NSItemProviderCGctF"
  },
  "title" : "onPasteCommand(of:perform:)"
}
-->

# onPasteCommand(of:perform:)

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

```
nonisolated func onPasteCommand(of supportedContentTypes: [UTType], perform payloadAction: @escaping ([NSItemProvider]) -> Void) -> some View
```

## Parameters

`supportedContentTypes`

The uniform type identifiers that describe the
types of content this view can accept through a paste action.
If the Clipboard doesn’t contain any of the supported types, the
Paste command doesn’t trigger.

`payloadAction`

The action to perform when the Paste command
triggers. The action closure’s parameter contains items from the
Clipboard with the types you specify in the `supportedContentTypes`
parameter.

## Return Value

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

## Discussion

Pass an array of uniform type identifiers to the `supportedContentTypes`
parameter. Place the higher priority types closer to the beginning of
the array. The Clipboard items that the `action` closure receives have
the most preferred type out of all the types the source supports.

For example, if your app can handle plain text and rich text, but you
prefer rich text, place the rich text type first in the array. If rich
text is available when the paste action occurs, the `action` closure
passes that rich text along.

---

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)