---
title: PasteButton
framework: swiftui
role: symbol
role_heading: Structure
path: swiftui/pastebutton
---

# PasteButton

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

## Declaration

```swift
nonisolated struct PasteButton
```

## Overview

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(_:), labelStyle(_:), and 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 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.

## Topics

### Creating a paste button

- [init(supportedContentTypes:payloadAction:)](swiftui/pastebutton/init(supportedcontenttypes:payloadaction:).md)
- [init(payloadType:onPaste:)](swiftui/pastebutton/init(payloadtype:onpaste:).md)

### Deprecated initializers

- [init(supportedTypes:payloadAction:)](swiftui/pastebutton/init(supportedtypes:payloadaction:).md)
- [init(supportedTypes:validator:payloadAction:)](swiftui/pastebutton/init(supportedtypes:validator:payloadaction:).md)
- [init(supportedContentTypes:validator:payloadAction:)](swiftui/pastebutton/init(supportedcontenttypes:validator:payloadaction:).md)

## Relationships

### Conforms To

- [View](swiftui/view.md)

## See Also

### Creating special-purpose buttons

- [EditButton](swiftui/editbutton.md)
- [RenameButton](swiftui/renamebutton.md)
