1e41f4b71Sopenharmony_ci# Custom Property
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciYou can set custom properties on components. These custom properties can be obtained on their corresponding FrameNodes, allowing for more flexible component management.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci>  **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci>  The initial APIs of this module are supported since API version 12. Updates will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci## customProperty
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_cicustomProperty(name: string, value: Optional\<Object>)
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ciSets a custom property for this component. This API does not work for [custom components](../../../quick-start/arkts-create-custom-components.md#creating-a-custom-component).
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 12.
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci**Parameters** 
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci| Name | Type                                                | Mandatory | Description                                                        |
24e41f4b71Sopenharmony_ci| ------ | ---------------------------------------------------- | ---- | ------------------------------------------------------------ |
25e41f4b71Sopenharmony_ci| name  | string | Yes  | Name of the custom property. |
26e41f4b71Sopenharmony_ci| value  | Optional\<Object> | Yes  | Value of the custom property. |
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci## Optional<sup>12+</sup>
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ciOptional\<T>
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ciDefines the Optional type. The value can be **undefined**.
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 12.
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci## Example
42e41f4b71Sopenharmony_ci```ts
43e41f4b71Sopenharmony_ci// xxx.ets
44e41f4b71Sopenharmony_ciimport { FrameNode, UIContext } from '@kit.ArkUI';
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci@Entry
47e41f4b71Sopenharmony_ci@Component
48e41f4b71Sopenharmony_cistruct CustomPropertyExample {
49e41f4b71Sopenharmony_ci  build() {
50e41f4b71Sopenharmony_ci    Column() {
51e41f4b71Sopenharmony_ci      Text('text')
52e41f4b71Sopenharmony_ci      Button('print').onClick(() => {
53e41f4b71Sopenharmony_ci        const uiContext: UIContext = this.getUIContext();
54e41f4b71Sopenharmony_ci        if (uiContext) {
55e41f4b71Sopenharmony_ci          const node: FrameNode | null = uiContext.getFrameNodeById("Test_Column") || null;
56e41f4b71Sopenharmony_ci          if (node) {
57e41f4b71Sopenharmony_ci            for (let i = 1; i < 4; i++) {
58e41f4b71Sopenharmony_ci              const key = 'customProperty' + i;
59e41f4b71Sopenharmony_ci              const property = node.getCustomProperty(key);
60e41f4b71Sopenharmony_ci              console.log(key, JSON.stringify(property));
61e41f4b71Sopenharmony_ci            }
62e41f4b71Sopenharmony_ci          }
63e41f4b71Sopenharmony_ci        }
64e41f4b71Sopenharmony_ci      })
65e41f4b71Sopenharmony_ci    }
66e41f4b71Sopenharmony_ci    .id('Test_Column')
67e41f4b71Sopenharmony_ci    .customProperty('customProperty1', {
68e41f4b71Sopenharmony_ci      'number': 10,
69e41f4b71Sopenharmony_ci      'string': 'this is a string',
70e41f4b71Sopenharmony_ci      'bool': true,
71e41f4b71Sopenharmony_ci      'object': {
72e41f4b71Sopenharmony_ci        'name': 'name',
73e41f4b71Sopenharmony_ci        'value': 100
74e41f4b71Sopenharmony_ci      }
75e41f4b71Sopenharmony_ci    })
76e41f4b71Sopenharmony_ci    .customProperty('customProperty2', {})
77e41f4b71Sopenharmony_ci    .customProperty('customProperty2', undefined)
78e41f4b71Sopenharmony_ci    .width('100%')
79e41f4b71Sopenharmony_ci    .height('100%')
80e41f4b71Sopenharmony_ci  }
81e41f4b71Sopenharmony_ci}
82e41f4b71Sopenharmony_ci```
83