1e41f4b71Sopenharmony_ci# Using PasteButton 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **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. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ciAfter 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. 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ciFor 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. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ciThe following figure shows the effect of **PasteButton** component. 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci## Constraints 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci- The temporary authorization will be automatically revoked when the screen turns off, the app switches to the background, or the app exits. 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci- During the authorization period, there is no limit on the number of API calls. 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci- 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. 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci## How to Develop 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ciThe following procedure implements the following: After **Paste** is tapped, the text is pasted to the text box. See the figure above. 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci1. Import the dependency **pasteboard**. 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci ```ts 28e41f4b71Sopenharmony_ci import { pasteboard } from '@kit.BasicServicesKit'; 29e41f4b71Sopenharmony_ci ``` 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci2. Add the text boxes and **PasteButton** component. 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci **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. 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci 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. 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci 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. 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci ```ts 40e41f4b71Sopenharmony_ci import { pasteboard, BusinessError } from '@kit.BasicServicesKit'; 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci @Entry 43e41f4b71Sopenharmony_ci @Component 44e41f4b71Sopenharmony_ci struct Index { 45e41f4b71Sopenharmony_ci @State message: string = ''; 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci build() { 48e41f4b71Sopenharmony_ci Row() { 49e41f4b71Sopenharmony_ci Column({ space: 10 }) { 50e41f4b71Sopenharmony_ci TextInput({placeholder: 'Please enter the verification code.', text: this.message}) 51e41f4b71Sopenharmony_ci PasteButton() 52e41f4b71Sopenharmony_ci .padding({top: 12, bottom: 12, left: 24, right: 24}) 53e41f4b71Sopenharmony_ci .onClick((event: ClickEvent, result: PasteButtonOnClickResult) => { 54e41f4b71Sopenharmony_ci if (PasteButtonOnClickResult.SUCCESS === result) { 55e41f4b71Sopenharmony_ci pasteboard.getSystemPasteboard().getData((err: BusinessError, pasteData: pasteboard.PasteData) => { 56e41f4b71Sopenharmony_ci if (err) { 57e41f4b71Sopenharmony_ci console.error(`Failed to get paste data. Code is ${err.code}, message is ${err.message}`); 58e41f4b71Sopenharmony_ci return; 59e41f4b71Sopenharmony_ci } 60e41f4b71Sopenharmony_ci // The content to paste is '123456'. 61e41f4b71Sopenharmony_ci this.message = pasteData.getPrimaryText(); 62e41f4b71Sopenharmony_ci }); 63e41f4b71Sopenharmony_ci } 64e41f4b71Sopenharmony_ci }) 65e41f4b71Sopenharmony_ci } 66e41f4b71Sopenharmony_ci .width('100%') 67e41f4b71Sopenharmony_ci } 68e41f4b71Sopenharmony_ci .height('100%') 69e41f4b71Sopenharmony_ci } 70e41f4b71Sopenharmony_ci } 71e41f4b71Sopenharmony_ci ``` 72