• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Enable/Disable
2
3The **enabled** attribute sets whether a component responds to user interactions, such as [click events](ts-universal-events-click.md), [touch events](ts-universal-events-touch.md), [drag events](ts-universal-events-drag-drop.md), [key events](ts-universal-events-key.md), [focus events](ts-universal-focus-event.md), and [mouse events](ts-universal-mouse-key.md).
4
5>  **NOTE**
6>
7>  The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
8
9
10## Attributes
11
12
13| Name   | Type| Description                                                        |
14| ------- | -------- | ------------------------------------------------------------ |
15| enabled | boolean  | Whether the component responds to user interactions, including clicks and touches. The value **true** means that the component responds to user interactions, and **false** means the opposite.<br>Default value: **true**<br>Since API version 9, this API is supported in ArkTS widgets. |
16
17
18## Example
19
20```ts
21// xxx.ets
22@Entry
23@Component
24struct EnabledExample {
25
26  build() {
27    Flex({ justifyContent: FlexAlign.SpaceAround }) {
28      // The component does not respond to clicks.
29      Button('disable').enabled(false).backgroundColor(0x317aff).opacity(0.4)
30      Button('enable').backgroundColor(0x317aff)
31    }
32    .width('100%')
33    .padding({ top: 5 })
34  }
35}
36```
37
38![en-us_image_0000001212218428](figures/en-us_image_0000001212218428.gif)
39