<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 10.15.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/PasteButton",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI11PasteButtonV"
  },
  "title" : "PasteButton"
}
-->

# PasteButton

A system button that reads items from the pasteboard and delivers it to a
closure.

```
nonisolated struct PasteButton
```

## Overview

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 [`buttonBorderShape(_:)`](/documentation/SwiftUI/View/buttonBorderShape(_:)),
[`labelStyle(_:)`](/documentation/SwiftUI/View/labelStyle(_:)), and [`tint(_:)`](/documentation/SwiftUI/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`](/documentation/SwiftUI/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()
    }
}
```

![macOS window titled PasteButton Demo showing (from left to right) a button](images/com.apple.SwiftUI/SwiftUI-PasteButton-pastedText@2x.png)

A paste button automatically validates and invalidates based on changes to
the pasteboard on iOS, but not on macOS.

## Topics

### Creating a paste button

[`init(supportedContentTypes:payloadAction:)`](/documentation/SwiftUI/PasteButton/init(supportedContentTypes:payloadAction:))

Creates a Paste button that accepts specific types of data from the
pasteboard.

[`init(payloadType:onPaste:)`](/documentation/SwiftUI/PasteButton/init(payloadType:onPaste:))

Creates an instance that accepts values of the specified type.

### Deprecated initializers

[`init(supportedTypes:payloadAction:)`](/documentation/SwiftUI/PasteButton/init(supportedTypes:payloadAction:))

Creates a Paste button that accepts specific types of data from the
pasteboard.

[`init(supportedTypes:validator:payloadAction:)`](/documentation/SwiftUI/PasteButton/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.

[`init(supportedContentTypes:validator:payloadAction:)`](/documentation/SwiftUI/PasteButton/init(supportedContentTypes: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.



---

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)