<!--
{
  "availability" : [
    "macOS: 10.15.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/PasteButton/init(supportedTypes:validator:payloadAction:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI11PasteButtonV14supportedTypes9validator13payloadActionACSaySSG_xSgSaySo14NSItemProviderCGcyxctclufc"
  },
  "title" : "init(supportedTypes:validator:payloadAction:)"
}
-->

# init(supportedTypes:validator:payloadAction:)

Creates a Paste button that accepts specific types of data from the
pasteboard, performing a custom validation of the data before sending it
to your app.

```
nonisolated init<Payload>(supportedTypes: [String], validator: @escaping ([NSItemProvider]) -> Payload?, payloadAction: @escaping (Payload) -> Void)
```

## Parameters

`supportedTypes`

The exact uniform type identifiers supported
by the button. If the pasteboard doesn’t contain any of the
supported types, the button becomes disabled.

`validator`

A handler that receives those contents of the pasteboard
that conform to `payloadAction`. Load and inspect these
items to determine whether to validate the button. If you load a
valid item, return it from this closure. If the pasteboard doesn’t
contain any valid items, return `nil` to invalidate the button.

`payloadAction`

The handler called when the user clicks the button.
This closure receives the preprocessed result of `validator`.

## Discussion

Set the contents of `supportedTypes` in order of your app’s
preference for its supported types. The Paste button takes the
most-preferred type that the pasteboard source supports and delivers
this to the `validator` closure.

---

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)