A system button that reads items from the pasteboard and delivers it to a
closure.
Use a paste button when you want to provide a button for pasting items from
the system pasteboard into your app. The system provides a button
appearance and label appropriate to the current environment. However, you
can use view modifiers like ``View/buttonBorderShape(_:)``,
``View/labelStyle(_:)``, and ``View/tint(_:)`` to customize the button
in some contexts.
You declare what type of items your app will accept; use a type that
conforms to the
<doc://com.apple.documentation/documentation/coretransferable/transferable>
protocol. When the user taps or clicks the button, your closure receives the
pasteboard items in the specified type.
In the following example, a paste button declares that it accepts a string.
When the user taps or clicks the button, the sample's closure receives an
array of strings and sets the first as the value of `pastedText`, which
updates a nearby ``Text`` view.
@State private var pastedText: String = ""
var body: some View {
HStack {
PasteButton(payloadType: String.self) { strings in
pastedText = strings[0]
}
Divider()
Text(pastedText)
Spacer()
}
}

A paste button automatically validates and invalidates based on changes to
the pasteboard on iOS, but not on macOS.
Creates a Paste button that accepts specific types of data from the
pasteboard.
Set the contents of `supportedContentTypes` 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 `payloadAction` closure.
- Parameters:
- supportedContentTypes: The exact uniform type identifiers supported
by the button. If the pasteboard doesn't contain any of the
supported types, the button becomes disabled.
- payloadAction: The handler to call when the user clicks the Paste
button and the pasteboard has items that conform to
`supportedContentTypes`. This closure receives an array of
item providers that you use to inspect and load the pasteboard data.
Skipped declarations
2 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
PasteButton.init(payloadType:onPaste:)
Passing a Swift type itself is not supported.
PasteButton.body
This protocol needs associated types that cannot yet cross the bridge.