• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Accessibility
2
3You can set accessibility attributes and events for components.
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## accessibilityGroup
10
11accessibilityGroup(value: boolean)
12
13Sets the accessibility group.
14
15**System capability**: SystemCapability.ArkUI.ArkUI.Full
16
17**Parameters**
18
19| Name| Type   | Mandatory| Description                                                        |
20| ------ | ------- | ---- | ------------------------------------------------------------ |
21| value  | boolean | Yes  | Accessibility group. If this attribute is set to **true**, the component and all its child components form an entire selectable component, and the accessibility service will no longer be available for the content of its child components.<br>Default value: **false**|
22
23## accessibilityText
24
25accessibilityText(value: string)
26
27Sets the accessibility text.
28
29**System capability**: SystemCapability.ArkUI.ArkUI.Full
30
31**Parameters**
32
33| Name| Type  | Mandatory| Description                                                        |
34| ------ | ------ | ---- | ------------------------------------------------------------ |
35| value  | string | Yes  | Accessibility text. If a component does not contain text information, it will not be read when the component is selected by the screen reader. In this case, the screen reader user cannot know which component is selected. To solve this problem, you can set this attribute for components without text information. When the component is selected by the screen reader, the specified accessibility text will be read, informing the user which component is selected.<br>Default value: **""**<br>**NOTE**<br>If a component with this attribute set contains text information, only the accessibility text will be read.<br>If a component with its **accessibilityGroup** attribute set to **true** does not have **accessibilityText** set and does not contain text information, text concatenation will be performed on its child components (depth first).|
36
37## accessibilityDescription
38
39accessibilityDescription(value: string)
40
41Sets the accessibility description.
42
43**System capability**: SystemCapability.ArkUI.ArkUI.Full
44
45**Parameters**
46
47| Name| Type  | Mandatory| Description                                                        |
48| ------ | ------ | ---- | ------------------------------------------------------------ |
49| value  | string | Yes  | Accessibility description. You can specify further explanation of the current component, for example, possible operation consequences, especially those that cannot be learned from component attributes and accessibility text. If a component contains both text information and the accessibility description, the text is read first and then the accessibility description, when the component is selected.<br>Default value: **""**|
50
51## accessibilityLevel
52
53accessibilityLevel(value: string)
54
55Sets the accessibility level.
56
57**System capability**: SystemCapability.ArkUI.ArkUI.Full
58
59**Parameters**
60
61| Name| Type  | Mandatory| Description                                                        |
62| ------ | ------ | ---- | ------------------------------------------------------------ |
63| value  | string | Yes  | Accessibility level, which is used to decide whether a component can be identified by the accessibility service.<br>The options are as follows:<br>**"auto"**: The value is converted to **"yes"** or **"no"** based on the component.<br>**"yes"**: The current component is selectable for the accessibility service.<br>**"no"**: The current component is not selectable for the accessibility service.<br>**"no-hide-descendants"**: The current component and all its child components are not selectable for the accessibility service.<br>**Default value**: **"auto"**<br>**NOTE**<br>When the **accessibilityLevel** attribute of the following components is set to **"auto"**, they are selectable for the accessibility service: Checkbox, CheckboxGroup, Gauge, Marquee, MenuItem, MenuItemGroup, Menu, Navigation, DatePicker, Progress, Radio, Rating, ScrollBar, Select, Slider, Stepper, Text, TextClock, TextPicker, TextTimer, TimePicker, Toggle, Web.|
64
65## accessibilityVirtualNode<sup>11+</sup>
66
67accessibilityVirtualNode(builder: CustomBuilder)
68
69Sets the accessibility virtual node.
70
71**System capability**: SystemCapability.ArkUI.ArkUI.Full
72
73**Parameters**
74
75| Name| Type  | Mandatory| Description                                                        |
76| ------ | ------ | ---- | ------------------------------------------------------------ |
77| builder  | [CustomBuilder](../arkui-ts/ts-types.md#custombuilder8) | Yes  | Accessibility virtual node, which enables you to pass in a custom builder to the self-drawing component. The components in the custom builder are only laid out but not displayed at the backend. When the accessibility application obtains the accessibility node information, the node information in the custom builder is returned.|
78
79## Example
80
81```ts
82// xxx.ets
83@Entry
84@Component
85struct Index {
86
87  @Builder customAccessibilityNode() {
88    Column() {
89      Text(`virtual node`)
90    }
91    .width(10)
92    .height(10)
93  }
94
95  build() {
96    Row() {
97      Column() {
98        Text ("Text 1")
99          .fontSize(50)
100          .fontWeight(FontWeight.Bold)
101        Text ("Text 2")
102          .fontSize(50)
103          .fontWeight(FontWeight.Bold)
104      }
105      .width('100%')
106      .accessibilityGroup(true)
107      .accessibilityLevel("yes")
108      .accessibilityText ("Group")
109      .accessibilityDescription("The <Column> component is selectable , and the text to be read out is "Group".)
110      .accessibilityVirtualNode(this.customAccessibilityNode)
111    }
112    .height('100%')
113  }
114}
115```
116