You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update accessibility related APIs
* Add accessibilityValue prop to Touchable
* Modify the accessibilityValue prop description
* Using 'clear' instead of obvious
* Update touchablewithoutfeedback.md
Using 'clear' instead of obvious
* Moving more content into tables and reducing h-tag hierarchy
* Retooling opening paragraph and meta-description
* Tweaking intro copy
Copy file name to clipboardExpand all lines: docs/accessibility.md
+51-50Lines changed: 51 additions & 50 deletions
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,17 @@
1
1
---
2
2
id: accessibility
3
3
title: Accessibility
4
-
---
5
-
6
-
## Native App Accessibility (iOS and Android)
4
+
description: "Create mobile apps accessible to assistive technology with React Native's suite of APIs designed to work with iOS and Android."
7
5
8
-
Both iOS and Android provide APIs for making apps accessible to people with disabilities. In addition, both platforms provide bundled assistive technologies, like the screen readers VoiceOver (iOS) and TalkBack (Android) for the visually impaired. Similarly, in React Native we have included APIs designed to provide developers with support for making apps more accessible. Take note, iOS and Android differ slightly in their approaches, and thus the React Native implementations may vary by platform.
6
+
---
9
7
10
-
In addition to this documentation, you might find [this blog post](https://engineering.fb.com/ios/making-react-native-apps-accessible/) about React Native accessibility to be useful.
8
+
Both iOS and Android provide APIs for integrating apps with assitive technologies like the bundled screen readers VoiceOver (iOS) and Talkback (Android). React Native has complimentary APIs that let your app accommodate all users.
11
9
12
-
## Making Apps Accessible
10
+
> iOS and Android differ slightly in their approaches, and thus the React Native implementations may vary by platform.
13
11
14
-
###Accessibility properties
12
+
## Accessibility properties
15
13
16
-
####accessible (iOS, Android)
14
+
### accessible (iOS, Android)
17
15
18
16
When `true`, indicates that the view is an accessibility element. When a view is an accessibility element, it groups its children into a single selectable component. By default, all touchable elements are accessible.
19
17
@@ -28,7 +26,7 @@ On Android, `accessible={true}` property for a react-native View will be transla
28
26
29
27
In the above example, we can't get accessibility focus separately on 'text one' and 'text two'. Instead we get focus on a parent view with 'accessible' property.
30
28
31
-
####accessibilityLabel (iOS, Android)
29
+
### accessibilityLabel (iOS, Android)
32
30
33
31
When a view is marked as accessible, it is a good practice to set an accessibilityLabel on the view, so that people who use VoiceOver know what element they have selected. VoiceOver will read this string when a user selects the associated element.
34
32
@@ -47,7 +45,7 @@ To use, set the `accessibilityLabel` property to a custom string on your View, T
47
45
48
46
In the above example, the `accessibilityLabel` on the TouchableOpacity element would default to "Press me!". The label is constructed by concatenating all Text node children separated by spaces.
49
47
50
-
####accessibilityHint (iOS, Android)
48
+
### accessibilityHint (iOS, Android)
51
49
52
50
An accessibility hint helps users understand what will happen when they perform an action on the accessibility element when that result is not clear from the accessibility label.
53
51
@@ -69,11 +67,11 @@ iOS In the above example, VoiceOver will read the hint after the label, if the u
69
67
70
68
Android In the above example, Talkback will read the hint after the label. At this time, hints cannot be turned off on Android.
71
69
72
-
####accessibilityIgnoresInvertColors(iOS)
70
+
### accessibilityIgnoresInvertColors(iOS)
73
71
74
72
Inverting screen colors is an Accessibility feature that makes the iPhone and iPad easier on the eyes for some people with a sensitivity to brightness, easier to distinguish for some people with color blindness, and easier to make out for some people with low vision. However, sometimes you have views such as photos that you don't want to be inverted. In this case, you can set this property to be false so that these specific views won't have their colors inverted.
75
73
76
-
####accessibilityRole (iOS, Android)
74
+
### accessibilityRole (iOS, Android)
77
75
78
76
`accessibilityRole` communicates the purpose of a component to the user of an assistive technology.
79
77
@@ -107,47 +105,60 @@ Inverting screen colors is an Accessibility feature that makes the iPhone and iP
107
105
-**timer** Used to represent a timer.
108
106
-**toolbar** Used to represent a tool bar (a container of action buttons or components).
109
107
110
-
#### accessibilityStates (iOS, Android)
108
+
###accessibilityState (iOS, Android)
111
109
112
110
Describes the current state of a component to the user of an assistive technology.
113
111
114
-
`accessibilityStates` is an array of values, and may include any of the following:
112
+
`accessibilityState` is an object. It contains the following fields:
| disabled | Indicates whether the element is disabled or not. | boolean | No |
117
+
| selected | Indicates whether a selectable element is currently selected or not. | boolean | No |
118
+
| checked | Indicates the state of a checkable element. This field can either take a boolean or the "mixed" string to represent mixed checkboxes. | boolean or 'mixed' | No |
119
+
| busy | Indicates whether an element is currently busy or not. | boolean | No |
120
+
| expanded | Indicates whether an expandable element is currently expanded or collapsed. | boolean | No |
121
+
122
+
To use, set the `accessibilityState` to an object with a specific definition.
123
+
124
+
### accessibilityValue (iOS, Android)
125
+
126
+
Represents the current value of a component. It can be a textual description of a component's value, or for range-based components, such as sliders and progress bars, it contains range information (minimum, current, and maximum).
115
127
116
-
-**selected** Used when the element is in a selected state. For example, a button is selected.
117
-
-**disabled** Used when the element is disabled and cannot be interacted with.
118
-
-**checked** Used to indicate that a checkable element is currently checked.
119
-
-**unchecked** Used to indicate that a checkable element is not currently checked.
120
-
-**busy** Used to indicate that an element is currently busy.
121
-
-**expanded** Used to indicate that an expandable element is currently expanded.
122
-
-**collapsed** Used to indicate that an expandable element is currently collapsed.
128
+
`accessibilityValue` is an object. It contains the following fields:
123
129
124
-
To use, set the `accessibilityStates` to an array containing the list of current states.
| min | The minimum value of this component's range. | integer | Required if `now` is set. |
133
+
| max | The maximum value of this component's range. | integer | Required if `now` is set. |
134
+
| now | The current value of this component's range. | integer | No |
135
+
| text | A textual description of this component's value. Will override `min`, `now`, and `max` if set. | string | No |
125
136
126
-
####accessibilityViewIsModal (iOS)
137
+
### accessibilityViewIsModal (iOS)
127
138
128
139
A Boolean value indicating whether VoiceOver should ignore the elements within views that are siblings of the receiver.
129
140
130
141
For example, in a window that contains sibling views `A` and `B`, setting `accessibilityViewIsModal` to `true` on view `B` causes VoiceOver to ignore the elements in the view `A`. On the other hand, if view `B` contains a child view `C` and you set `accessibilityViewIsModal` to `true` on view `C`, VoiceOver does not ignore the elements in view `A`.
131
142
132
-
####accessibilityElementsHidden (iOS)
143
+
### accessibilityElementsHidden (iOS)
133
144
134
145
A Boolean value indicating whether the accessibility elements contained within this accessibility element are hidden.
135
146
136
147
For example, in a window that contains sibling views `A` and `B`, setting `accessibilityElementsHidden` to `true` on view `B` causes VoiceOver to ignore the elements in the view `B`. This is similar to the Android property `importantForAccessibility="no-hide-descendants"`.
137
148
138
-
####onAccessibilityTap (iOS)
149
+
### onAccessibilityTap (iOS, Android)
139
150
140
151
Use this property to assign a custom function to be called when someone activates an accessible element by double tapping on it while it's selected.
141
152
142
-
####onMagicTap (iOS)
153
+
### onMagicTap (iOS)
143
154
144
155
Assign this property to a custom function which will be called when someone performs the "magic tap" gesture, which is a double-tap with two fingers. A magic tap function should perform the most relevant action a user could take on a component. In the Phone app on iPhone, a magic tap answers a phone call, or ends the current one. If the selected element does not have an `onMagicTap` function, the system will traverse up the view hierarchy until it finds a view that does.
145
156
146
-
####onAccessibilityEscape (iOS)
157
+
### onAccessibilityEscape (iOS)
147
158
148
159
Assign this property to a custom function which will be called when someone performs the "escape" gesture, which is a two finger Z shaped gesture. An escape function should move back hierarchically in the user interface. This can mean moving up or back in a navigation hierarchy or dismissing a modal user interface. If the selected element does not have an `onAccessibilityEscape` function, the system will attempt to traverse up the view hierarchy until it finds a view that does or bonk to indicate it was unable to find one.
149
160
150
-
####accessibilityLiveRegion (Android)
161
+
### accessibilityLiveRegion (Android)
151
162
152
163
When components dynamically change, we want TalkBack to alert the end user. This is made possible by the ‘accessibilityLiveRegion’ property. It can be set to ‘none’, ‘polite’ and ‘assertive’:
153
164
@@ -168,7 +179,7 @@ When components dynamically change, we want TalkBack to alert the end user. This
168
179
169
180
In the above example method \_addOne changes the state.count variable. As soon as an end user clicks the TouchableWithoutFeedback, TalkBack reads text in the Text view because of its 'accessibilityLiveRegion=”polite”' property.
170
181
171
-
####importantForAccessibility (Android)
182
+
### importantForAccessibility (Android)
172
183
173
184
In the case of two overlapping UI components with the same parent, default accessibility focus can have unpredictable behavior. The ‘importantForAccessibility’ property will resolve this by controlling if a view fires accessibility events and if it is reported to accessibility services. It can be set to ‘auto’, ‘yes’, ‘no’ and ‘no-hide-descendants’ (the last value will force accessibility services to ignore the component and all of its children).
174
185
@@ -187,7 +198,7 @@ In the case of two overlapping UI components with the same parent, default acces
187
198
188
199
In the above example, the yellow layout and its descendants are completely invisible to TalkBack and all other accessibility services. So we can use overlapping views with the same parent without confusing TalkBack.
189
200
190
-
###Accessibility Actions
201
+
## Accessibility Actions
191
202
192
203
Accessibility actions allow an assistive technology to programmatically invoke the actions of a component. In order to support accessibility actions, a component must do two things:
193
204
@@ -240,39 +251,25 @@ To handle action requests, a component must implement an `onAccessibilityAction`
240
251
/>
241
252
```
242
253
243
-
###Checking if a Screen Reader is Enabled
254
+
## Checking if a Screen Reader is Enabled
244
255
245
256
The `AccessibilityInfo` API allows you to determine whether or not a screen reader is currently active. See the [AccessibilityInfo documentation](accessibilityinfo.md) for details.
246
257
247
-
###Sending Accessibility Events (Android)
258
+
## Sending Accessibility Events (Android)
248
259
249
-
Sometimes it is useful to trigger an accessibility event on a UI component (i.e. when a custom view appears on a screen or a custom radio button has been selected). Native UIManager module exposes a method ‘sendAccessibilityEvent’ for this purpose. It takes two arguments: view tag and a type of an event.
260
+
Sometimes it is useful to trigger an accessibility event on a UI component (i.e. when a custom view appears on a screen or set accessibility focus to a view). Native UIManager module exposes a method ‘sendAccessibilityEvent’ for this purpose. It takes two arguments: view tag and a type of an event. The supported event types are `typeWindowStateChanged`, `typeViewFocused` and `typeViewClicked`.
In the above example we've created a custom radio button that now behaves like a native one. More specifically, TalkBack now correctly announces changes to the radio button selection.
275
-
276
273
## Testing VoiceOver Support (iOS)
277
274
278
275
To enable VoiceOver, go to the Settings app on your iOS device (it's not available for simulator). Tap General, then Accessibility. There you will find many tools that people use to make their devices more usable, such as bolder text, increased contrast, and VoiceOver.
Copy file name to clipboardExpand all lines: docs/touchablewithoutfeedback.md
+84-18Lines changed: 84 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,26 @@ function MyComponent(props) {
37
37
38
38
---
39
39
40
+
### `accessible`
41
+
42
+
When `true`, indicates that the view is an accessibility element. By default, all the touchable elements are accessible.
43
+
44
+
| Type | Required |
45
+
| ---- | -------- |
46
+
| bool | No |
47
+
48
+
---
49
+
50
+
### `accessibilityLabel`
51
+
52
+
Overrides the text that's read by the screen reader when the user interacts with the element. By default, the label is constructed by traversing all the children and accumulating all the `Text` nodes separated by space.
53
+
54
+
| Type | Required |
55
+
| ------ | -------- |
56
+
| string | No |
57
+
58
+
---
59
+
40
60
### `accessibilityHint`
41
61
42
62
An accessibility hint helps users understand what will happen when they perform an action on the accessibility element when that result is not clear from the accessibility label.
@@ -47,45 +67,91 @@ An accessibility hint helps users understand what will happen when they perform
47
67
48
68
---
49
69
50
-
### `accessibilityLabel`
70
+
### `accessibilityRole`
51
71
52
-
Overrides the text that's read by the screen reader when the user interacts with the element. By default, the label is constructed by traversing all the children and accumulating all the `Text` nodes separated by space.
72
+
`accessibilityRole` communicates the purpose of a component to the user of an assistive technology.
73
+
74
+
`accessibilityRole` can be one of the following:
75
+
76
+
-`'none'` - Used when the element has no role.
77
+
-`'button'` - Used when the element should be treated as a button.
78
+
-`'link'` - Used when the element should be treated as a link.
79
+
-`'search'` - Used when the text field element should also be treated as a search field.
80
+
-`'image'` - Used when the element should be treated as an image. Can be combined with button or link, for example.
81
+
-`'keyboardkey'` - Used when the element acts as a keyboard key.
82
+
-`'text'` - Used when the element should be treated as static text that cannot change.
83
+
-`'adjustable'` - Used when an element can be "adjusted" (e.g. a slider).
84
+
-`'imagebutton'` - Used when the element should be treated as a button and is also an image.
85
+
-`'header'` - Used when an element acts as a header for a content section (e.g. the title of a navigation bar).
86
+
-`'summary'` - Used when an element can be used to provide a quick summary of current conditions in the app when the app first launches.
87
+
-`'alert'` - Used when an element contains important text to be presented to the user.
88
+
-`'checkbox'` - Used when an element represents a checkbox which can be checked, unchecked, or have mixed checked state.
89
+
-`'combobox'` - Used when an element represents a combo box, which allows the user to select among several choices.
90
+
-`'menu'` - Used when the component is a menu of choices.
91
+
-`'menubar'` - Used when a component is a container of multiple menus.
92
+
-`'menuitem'` - Used to represent an item within a menu.
93
+
-`'progressbar'` - Used to represent a component which indicates progress of a task.
94
+
-`'radio'` - Used to represent a radio button.
95
+
-`'radiogroup'` - Used to represent a group of radio buttons.
96
+
-`'scrollbar'` - Used to represent a scroll bar.
97
+
-`'spinbutton'` - Used to represent a button which opens a list of choices.
98
+
-`'switch'` - Used to represent a switch which can be turned on and off.
99
+
-`'tab'` - Used to represent a tab.
100
+
-`'tablist'` - Used to represent a list of tabs.
101
+
-`'timer'` - Used to represent a timer.
102
+
-`'toolbar'` - Used to represent a tool bar (a container of action buttons or components).
53
103
54
104
| Type | Required |
55
105
| ------ | -------- |
56
106
| string | No |
57
107
58
108
---
59
109
60
-
### `accessibilityRole`
110
+
### `accessibilityState`
61
111
62
-
| Type | Required |
63
-
| ------------------ | -------- |
64
-
| AccessibilityRoles | No |
112
+
Describes the current state of a component to the user of an assistive technology.
113
+
114
+
See the [Accessibility guide](accessibility.md#accessibilitystate-ios-android) for more information.
| object: {disabled: bool, selected: bool, checked: bool or 'mixed', busy: bool, expanded: bool} | No |
65
119
66
120
---
67
121
68
-
### `accessibilityStates`
122
+
### `accessibilityActions`
123
+
124
+
Accessibility actions allow an assistive technology to programmatically invoke the actions of a component. The `accessibilityActions` property should contain a list of action objects. Each action object should contain the field name and label.
69
125
70
-
| Type | Required |
71
-
| ---------------------------- | -------- |
72
-
| array of AccessibilityStates | No |
126
+
See the [Accessibility guide](accessibility.md#accessibility-actions) for more information.
127
+
128
+
| Type | Required |
129
+
| ----- | -------- |
130
+
| array | No |
73
131
74
132
---
75
133
76
-
### `accessibilityState`
134
+
### `onAccessibilityAction`
77
135
78
-
| Type | Required |
79
-
| ------ | -------- |
80
-
| Object | No |
136
+
Invoked when the user performs the accessibility actions. The only argument to this function is an event containing the name of the action to perform.
137
+
138
+
See the [Accessibility guide](accessibility.md#accessibility-actions) for more information.
139
+
140
+
| Type | Required |
141
+
| -------- | -------- |
142
+
| function | No |
81
143
82
144
---
83
145
84
-
### `accessible`
146
+
### `accessibilityValue`
85
147
86
-
| Type | Required |
87
-
| ---- | -------- |
88
-
| bool | No |
148
+
Represents the current value of a component. It can be a textual description of a component's value, or for range-based components, such as sliders and progress bars, it contains range information (minimum, current, and maximum).
149
+
150
+
See the [Accessibility guide](accessibility.md#accessibilityvalue-ios-android) for more information.
0 commit comments