1# Click Effect
2
3You can set the click effect for a component to define how it behaves when clicked.
4
5>  **NOTE**
6>
7> The APIs of this module are supported since API version 10. Updates will be marked with a superscript to indicate their earliest API version.
8
9## clickEffect
10
11clickEffect(value: ClickEffect | null)
12
13Click effect of the component.
14
15**System capability**: SystemCapability.ArkUI.ArkUI.Full
16
17**Parameters**
18
19| Name| Type                                                 | Mandatory| Description                                                        |
20| ------ | ----------------------------------------------------- | ---- | ------------------------------------------------------------ |
21| value  | [ClickEffect](#clickeffect) \| null | Yes  | Click effect of the component.<br>**NOTE**<br>You can remove the click effect by setting this attribute to **undefined** or **null**.<br>Avoid using this attribute in scenarios where the component size dynamically changes.<br>This attribute is not supported when the component cannot trigger a universal event.|
22
23## ClickEffect
24
25| Name | Type                                                   | Mandatory| Description                                                        |
26| ----- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ |
27| level | [ClickEffectLevel](ts-appendix-enums.md#clickeffectlevel10) | Yes  | Click effect of the component.<br>**NOTE**<br>If **level** is set to **undefined** or **null**, the click effect corresponding to **ClickEffectLevel.LIGHT** will be used. For details about the zoom ratio, see the description of **scale**.|
28| scale | number                                                      | No  | Zoom ratio. This parameter works based on the setting of **ClickEffectLevel**.<br>**NOTE**<br>The default value of this parameter varies by the value of **level**.<br>If **level** is set to **ClickEffectLevel.LIGHT**, the default value is **0.90**.<br>If **level** is set to **ClickEffectLevel.MIDDLE** or **ClickEffectLevel.HEAVY**, the default value is **0.95**.<br>If **level** is set to **undefined** or **null** (both of which evaluate to **ClickEffectLevel.LIGHT**), the default value is **0.90**.<br>If **scale** is set to **undefined** or **null**, the default zoom ratio for the set level will be used.<br>|
29
30## Example
31
32```ts
33// xxx.ets
34@Entry
35@Component
36struct ToggleExample {
37  build() {
38    Column({ space: 10 }) {
39      Text('type: Switch').fontSize(12).fontColor(0xcccccc).width('90%')
40      Flex({ justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) {
41        Toggle({ type: ToggleType.Switch, isOn: false })
42          .clickEffect({level:ClickEffectLevel.LIGHT})
43          .selectedColor('#007DFF')
44          .switchPointColor('#FFFFFF')
45          .onChange((isOn: boolean) => {
46            console.info('Component status:' + isOn)
47          })
48
49        Toggle({ type: ToggleType.Switch, isOn: true })
50          .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
51          .selectedColor('#007DFF')
52          .switchPointColor('#FFFFFF')
53          .onChange((isOn: boolean) => {
54            console.info('Component status:' + isOn)
55          })
56      }
57
58      Text('type: Checkbox').fontSize(12).fontColor(0xcccccc).width('90%')
59      Flex({ justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) {
60        Toggle({ type: ToggleType.Checkbox, isOn: false })
61          .clickEffect({level:ClickEffectLevel.MIDDLE})
62          .size({ width: 20, height: 20 })
63          .selectedColor('#007DFF')
64          .onChange((isOn: boolean) => {
65            console.info('Component status:' + isOn)
66          })
67
68        Toggle({ type: ToggleType.Checkbox, isOn: true })
69          .clickEffect({level:ClickEffectLevel.MIDDLE, scale: 0.5})
70          .size({ width: 20, height: 20 })
71          .selectedColor('#007DFF')
72          .onChange((isOn: boolean) => {
73            console.info('Component status:' + isOn)
74          })
75      }
76
77      Text('type: Button').fontSize(12).fontColor(0xcccccc).width('90%')
78      Flex({ justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) {
79        Toggle({ type: ToggleType.Button, isOn: false }) {
80          Text('status button').fontColor('#182431').fontSize(12)
81        }.width(106)
82        .clickEffect({level:ClickEffectLevel.HEAVY})
83        .selectedColor('rgba(0,125,255,0.20)')
84        .onChange((isOn: boolean) => {
85          console.info('Component status:' + isOn)
86        })
87
88        Toggle({ type: ToggleType.Button, isOn: true }) {
89          Text('status button').fontColor('#182431').fontSize(12)
90        }.width(106)
91        .clickEffect({level:ClickEffectLevel.HEAVY, scale: 0.5})
92        .selectedColor('rgba(0,125,255,0.20)')
93        .onChange((isOn: boolean) => {
94          console.info('Component status:' + isOn)
95        })
96      }
97    }.width('100%').padding(24)
98  }
99}
100```
101
102![clickeffect](figures/clickeffect.gif)
103