1# PasteButton
2
3The **\<PasteButton>** security component allows you to obtain temporary pasteboard permission from the user by their touching the component.
4
5> **NOTE**
6>
7> This component is supported since API version 10. Updates will be marked with a superscript to indicate their earliest API version.
8
9## Child Components
10
11Not supported
12
13## APIs
14
15### PasteButton
16
17PasteButton()
18
19Creates a Paste button with an icon, text, and background.
20
21You may want to learn the [restrictions on security component styles](../../../security/AccessToken/security-component-overview.md#constraints) to avoid authorization failures caused by incompliant styles.
22
23**Atomic service API**: This API can be used in atomic services since API version 11.
24
25**System capability**: SystemCapability.ArkUI.ArkUI.Full
26
27### PasteButton
28
29PasteButton(option:PasteButtonOptions)
30
31Creates a Paste button that contains the specified elements.
32
33You may want to learn the [restrictions on security component styles](../../../security/AccessToken/security-component-overview.md#constraints) to avoid authorization failures caused by incompliant styles.
34
35**Atomic service API**: This API can be used in atomic services since API version 11.
36
37**System capability**: SystemCapability.ArkUI.ArkUI.Full
38
39**Parameters**
40
41| Name| Type| Mandatory| Description|
42| -------- | -------- | -------- | -------- |
43| option | [PasteButtonOptions](#pastebuttonoptions) | No| Options for creating the Paste button.<br>Default value:<br>{<br>icon: PasteIconStyle.LINES,<br>text: PasteDescription.PASTE,<br>buttonType: ButtonType.Capsule <br>} |
44
45## PasteButtonOptions
46
47**Atomic service API**: This API can be used in atomic services since API version 11.
48
49**System capability**: SystemCapability.ArkUI.ArkUI.Full
50
51| Name| Type| Mandatory| Description|
52| -------- | -------- | -------- | -------- |
53| icon | [PasteIconStyle](#pasteiconstyle) | No| Icon style of the Paste button.<br>If this parameter is not specified, no icon is contained. Either **icon** or **text**, or both, must be set.|
54| text | [PasteDescription](#pastedescription) | No| Text on the Paste button.<br>If this parameter is not specified, no text is contained. Either **icon** or **text**, or both, must be set.|
55| buttonType | [ButtonType](ts-basic-components-button.md#buttontype) | No| Background type of the Paste button.<br>If this parameter is not specified, the system uses a capsule-type button.|
56
57## Attributes
58
59This component can only inherit the [universal attributes of security components](ts-securitycomponent-attributes.md#attributes)
60
61## PasteIconStyle
62
63**Atomic service API**: This API can be used in atomic services since API version 11.
64
65**System capability**: SystemCapability.ArkUI.ArkUI.Full
66
67| Name| Value| Description|
68| -------- | -------- | -------- |
69| LINES | 0 | Line style icon.|
70
71## PasteDescription
72
73**Atomic service API**: This API can be used in atomic services since API version 11.
74
75**System capability**: SystemCapability.ArkUI.ArkUI.Full
76
77| Name| Value| Description|
78| -------- | -------- | -------- |
79| PASTE | 0 | The text on the Paste button is **Paste**.|
80
81## PasteButtonOnClickResult
82
83**Atomic service API**: This API can be used in atomic services since API version 11.
84
85**System capability**: SystemCapability.ArkUI.ArkUI.Full
86
87| Name| Value| Description|
88| -------- | -------- | -------- |
89| SUCCESS | 0 | The Paste button is touched successfully.|
90| TEMPORARY_AUTHORIZATION_FAILED | 1 | Temporary authorization fails after the Paste button is touched.|
91
92## Events
93
94Only the following events are supported.
95
96### onClick
97
98onClick(event: (event: ClickEvent, result: PasteButtonOnClickResult) =&gt; void)
99
100Called when a click event occurs.
101
102**Atomic service API**: This API can be used in atomic services since API version 11.
103
104**System capability**: SystemCapability.ArkUI.ArkUI.Full
105
106**Parameters**
107
108| Name| Type                  | Mandatory| Description                  |
109|------------|------|-------|---------|
110| event  | [ClickEvent](ts-universal-events-click.md#clickevent) |Yes|See **ClickEvent**.|
111| result | [PasteButtonOnClickResult](#pastebuttononclickresult)| Yes| Authorization result. After the authorization, the pasteboard content can be read.|
112
113## Example
114
115```ts
116// xxx.ets
117@Entry
118@Component
119struct Index {
120  build() {
121    Row() {
122      Column({space:10}) {
123        // Create a default button with an icon, text, and background.
124        PasteButton().onClick((event: ClickEvent, result: PasteButtonOnClickResult)=>{
125          console.info("result " + result)
126        })
127        // Whether an element is contained depends on whether the parameter corresponding to the element is specified. If buttonType is not passed in, the button uses the ButtonType.Capsule settings.
128        PasteButton({icon:PasteIconStyle.LINES})
129        // Create a button with only an icon and background. If the alpha value of the most significant eight bits of the background color is less than 0x1A, the system forcibly adjusts the alpha value to 0xFF.
130        PasteButton({icon:PasteIconStyle.LINES, buttonType:ButtonType.Capsule})
131          .backgroundColor(0x10007dff)
132        // Create a button with an icon, text, and background. If the alpha value of the most significant eight bits of the background color is less than 0x1A, the system forcibly adjusts the alpha value to 0xFF.
133        PasteButton({icon:PasteIconStyle.LINES, text:PasteDescription.PASTE, buttonType:ButtonType.Capsule})
134      }.width('100%')
135    }.height('100%')
136  }
137}
138```
139
140![en-us_image_0000001593677984](figures/en-us_image_0000001593677984.png)
141