1e41f4b71Sopenharmony_ci# QRCode 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **\<QRCode>** component is used to display a QR code. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci> The pixel count of the **\<QRCode>** component is subject to the content. If the component size is not large enough, the content may fail to be displayed. In this case, you need to resize the component. 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci## Child Components 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ciNot supported 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci## APIs 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ciQRCode(value: string) 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9. 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci**Parameters** 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 28e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 29e41f4b71Sopenharmony_ci| value | string | Yes | Content of the QR code. A maximum of 256 characters are supported. If this limit is exceeded, the first 256 characters are used.<br>**NOTE**<br>The string cannot be **null**, **undefined**, or empty. | 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci## Attributes 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ciIn addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported. 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci### color 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_cicolor(value: ResourceColor) 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ciSets the color of the QR code. 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9. 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci**Parameters** 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 50e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ------------ | 51e41f4b71Sopenharmony_ci| value | [ResourceColor](ts-types.md#resourcecolor) | Yes | QR code color. Default value: **'#ff182431'**<br> | 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ci### backgroundColor 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_cibackgroundColor(value: ResourceColor) 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ciSets the background color of the QR code. 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9. 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci**Parameters** 66e41f4b71Sopenharmony_ci 67e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 68e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ------------------------------------------------------------ | 69e41f4b71Sopenharmony_ci| value | [ResourceColor](ts-types.md#resourcecolor) | Yes | Background color of the QR code.<br>Default value: **Color.White**<br>Since API version 11, the default value is changed to **'#ffffffff'**. | 70e41f4b71Sopenharmony_ci 71e41f4b71Sopenharmony_ci### contentOpacity<sup>11+</sup> 72e41f4b71Sopenharmony_ci 73e41f4b71Sopenharmony_cicontentOpacity(value: number | Resource) 74e41f4b71Sopenharmony_ci 75e41f4b71Sopenharmony_ciSets the opacity of the QR code content. The minimum value is 0, and the maximum value is 1. 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci**Parameters** 82e41f4b71Sopenharmony_ci 83e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 84e41f4b71Sopenharmony_ci| ------ | ---------------------------------------------------- | ---- | ---------------------------------------- | 85e41f4b71Sopenharmony_ci| value | number \| [Resource](ts-types.md#resource) | Yes | Opacity of the QR code content.<br>Default value: **1** | 86e41f4b71Sopenharmony_ci 87e41f4b71Sopenharmony_ci 88e41f4b71Sopenharmony_ci## Events 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ciAmong the universal events, the [click event](ts-universal-events-click.md), [touch event](ts-universal-events-touch.md), and [show/hide event](ts-universal-events-show-hide.md) are supported. 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci 93e41f4b71Sopenharmony_ci## Example 94e41f4b71Sopenharmony_ci 95e41f4b71Sopenharmony_ci```ts 96e41f4b71Sopenharmony_ci// xxx.ets 97e41f4b71Sopenharmony_ci@Entry 98e41f4b71Sopenharmony_ci@Component 99e41f4b71Sopenharmony_cistruct QRCodeExample { 100e41f4b71Sopenharmony_ci private value: string = 'hello world' 101e41f4b71Sopenharmony_ci build() { 102e41f4b71Sopenharmony_ci Column({ space: 5 }) { 103e41f4b71Sopenharmony_ci Text('normal').fontSize(9).width('90%').fontColor(0xCCCCCC).fontSize(30) 104e41f4b71Sopenharmony_ci QRCode(this.value).width(140).height(140) 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci // Set the color for the QR code. 107e41f4b71Sopenharmony_ci Text('color').fontSize(9).width('90%').fontColor(0xCCCCCC).fontSize(30) 108e41f4b71Sopenharmony_ci QRCode(this.value).color(0xF7CE00).width(140).height(140) 109e41f4b71Sopenharmony_ci 110e41f4b71Sopenharmony_ci // Set the background color for the QR code. 111e41f4b71Sopenharmony_ci Text('backgroundColor').fontSize(9).width('90%').fontColor(0xCCCCCC).fontSize(30) 112e41f4b71Sopenharmony_ci QRCode(this.value).width(140).height(140).backgroundColor(Color.Orange) 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ci // Set the opacity of QR code content. 115e41f4b71Sopenharmony_ci Text('contentOpacity').fontSize(9).width('90%').fontColor(0xCCCCCC).fontSize(30) 116e41f4b71Sopenharmony_ci QRCode(this.value).width(140).height(140).color(Color.Black).contentOpacity(0.1) 117e41f4b71Sopenharmony_ci }.width('100%').margin({ top: 5 }) 118e41f4b71Sopenharmony_ci } 119e41f4b71Sopenharmony_ci} 120e41f4b71Sopenharmony_ci``` 121e41f4b71Sopenharmony_ci 122e41f4b71Sopenharmony_ci 123