1e41f4b71Sopenharmony_ci# Component Size Change Event
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe size change event is triggered whenever the component's size changes.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci>  **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci>  This feature is supported since API version 12. Updates will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci## onSizeChange
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_cionSizeChange(event: SizeChangeCallback): T
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ciTriggered when the component size changes due to layout updates. This event is not triggered for render attribute changes caused by re-rendering, such as changes of **translate** and **offset**.
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| event | [SizeChangeCallback](#sizechangecallback) | Yes  | Size of the component before and after the change.|
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci**Return value**
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci| Type| Description|
30e41f4b71Sopenharmony_ci| -------- | -------- |
31e41f4b71Sopenharmony_ci| T | Current component.|
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci## SizeChangeCallback
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ciSizeChangeCallback = (oldValue: SizeOptions, newValue: SizeOptions) => void
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ciInvoked when the component size changes.
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 12.
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci**Parameters**
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci| Name  | Type                     | Mandatory| Description                                                        |
48e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
49e41f4b71Sopenharmony_ci| oldValue | [SizeOptions](ts-types.md#sizeoptions) | Yes  | Width and height of the component before the change.|
50e41f4b71Sopenharmony_ci| newValue | [SizeOptions](ts-types.md#sizeoptions) | Yes  | Width and height of the component after the change.|
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci## Example
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci```ts
56e41f4b71Sopenharmony_ci// xxx.ets
57e41f4b71Sopenharmony_ci@Entry
58e41f4b71Sopenharmony_ci@Component
59e41f4b71Sopenharmony_cistruct AreaExample {
60e41f4b71Sopenharmony_ci  @State value: string = 'Text'
61e41f4b71Sopenharmony_ci  @State sizeValue: string = ''
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci  build() {
64e41f4b71Sopenharmony_ci    Column() {
65e41f4b71Sopenharmony_ci      Text(this.value)
66e41f4b71Sopenharmony_ci        .backgroundColor(Color.Green)
67e41f4b71Sopenharmony_ci        .margin(30)
68e41f4b71Sopenharmony_ci        .fontSize(20)
69e41f4b71Sopenharmony_ci        .onClick(() => {
70e41f4b71Sopenharmony_ci          this.value = this.value + 'Text'
71e41f4b71Sopenharmony_ci        })
72e41f4b71Sopenharmony_ci        .onSizeChange((oldValue: SizeOptions, newValue: SizeOptions) => {
73e41f4b71Sopenharmony_ci          console.info(`Ace: on size change, oldValue is ${JSON.stringify(oldValue)} value is ${JSON.stringify(newValue)}`)
74e41f4b71Sopenharmony_ci          this.sizeValue = JSON.stringify(newValue)
75e41f4b71Sopenharmony_ci        })
76e41f4b71Sopenharmony_ci      Text('new area is: \n' + this.sizeValue).margin({ right: 30, left: 30 })
77e41f4b71Sopenharmony_ci    }
78e41f4b71Sopenharmony_ci    .width('100%').height('100%').margin({ top: 30 })
79e41f4b71Sopenharmony_ci  }
80e41f4b71Sopenharmony_ci}
81e41f4b71Sopenharmony_ci```
82e41f4b71Sopenharmony_ci![onSizeChange](figures/onSizeChange.gif)
83