1# Using PasteButton
2
3The **PasteButton** component comes with the pasteboard (also called clipboard) read privilege, which allows an application to read data from the pasteboard without any prompt information.
4
5After the component integrated into your application is tapped, no authorization dialog box will be displayed when your application reads data from the pasteboard. You can use this component for any application that needs to read data from the pasteboard, while eliminating the pop-up windows.
6
7For example, if a user needs to copy a verification code (received from the Messaging application) to another application, the user has to touch and hold the input box, and select **Paste** from the options displayed. With the **PasteButton** component integrated into your application, the user only needs to tap the **Paste** button.
8
9The following figure shows the effect of **PasteButton** component.
10
11![](figures/PasteButton_effect.gif)
12
13## Constraints
14
15- The temporary authorization will be automatically revoked when the screen turns off, the application switches to the background, or the application exits.
16
17- During the authorization period, there is no limit on the number of API calls.
18
19- The **PasteButton** component must be visible and legible to users. You need to properly configure the component attributes such as the size and color to prevent authorization failures. If the authorization fails due to invalid component style, check the device error logs.
20
21## How to Develop
22
23The following procedure implements the following: After **Paste** is tapped, the text is pasted to the text box. See the figure above.
24
251. Import the dependency **pasteboard**.
26
27   ```ts
28   import { pasteboard } from '@kit.BasicServicesKit';
29   ```
30
312. Add the text boxes and **PasteButton** component.
32
33   **PasteButton** is a button-like component consisting of an icon, text, and background. Either the icon or text is mandatory, and the background is mandatory. The icon and text cannot be customized. You can only select from the existing options.
34
35   When declaring the API for creating a security component, you can determine whether to pass in parameters. If parameters are passed in, the component is created based on the specified parameters. If no parameter is passed in, a component with default icon, text, and background is created.
36
37   The following example uses the default parameters. For details, see [PasteButton](../../reference/apis-arkui/arkui-ts/ts-security-components-pastebutton.md). In addition, all security components inherit the [Security Component Universal Attributes](../../reference/apis-arkui/arkui-ts/ts-securitycomponent-attributes.md), which can be used to customize styles.
38
39   ```ts
40   import { pasteboard, BusinessError } from '@kit.BasicServicesKit';
41
42   @Entry
43   @Component
44   struct Index {
45     @State message: string = '';
46
47     build() {
48       Row() {
49         Column({ space: 10 }) {
50           TextInput({placeholder: 'Please enter the verification code.', text: this.message})
51           PasteButton()
52             .padding({top: 12, bottom: 12, left: 24, right: 24})
53             .onClick((event: ClickEvent, result: PasteButtonOnClickResult) => {
54               if (PasteButtonOnClickResult.SUCCESS === result) {
55                 pasteboard.getSystemPasteboard().getData((err: BusinessError, pasteData: pasteboard.PasteData) => {
56                   if (err) {
57                     console.error(`Failed to get paste data. Code is ${err.code}, message is ${err.message}`);
58                     return;
59                   }
60                   // The content to paste is '123456'.
61                   this.message = pasteData.getPrimaryText();
62                 });
63               }
64             })
65         }
66         .width('100%')
67       }
68       .height('100%')
69     }
70   }
71   ```
72