-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add docs page for accessibility support #1726
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
--- | ||
id: accesibility | ||
title: Accessibility | ||
layout: docs | ||
category: Guides | ||
permalink: docs/accessibility.html | ||
next: nativemodulesios | ||
--- | ||
|
||
# Accessibility | ||
|
||
Accessibility on iOS encompasses many topics, but for many, accessibility is synonymous with VoiceOver, a technology available since iOS 3.0. It acts as a screen reader, allowing people with visual impairments to use their iOS devices. Click [here](https://developer.apple.com/accessibility/ios/) to learn more. | ||
|
||
## Making Accessible Apps | ||
|
||
### Coding Accessibly | ||
|
||
#### accessible | ||
|
||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I'd do Also, I think it's not entirely clear what the implications of "it groups its children into a single selectable component" are for the developer - does this mean that an accessible component can only have a single child like Touchable components? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It basically means that they become a single selectable group. That is, you can't select a child of the group but you can select the group. For example, a table view cell may have multiple labels inside, but you would want the table view cell to be accessible so the cell itself becomes a single selectable element. |
||
|
||
#### accessibilityLabel | ||
|
||
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. | ||
|
||
To use, simply set the `accessibilityLabel` property to a custom string on your View: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think "simply" is unnecessary here |
||
|
||
```javascript | ||
<TouchableOpacity accessible={true} accessibilityLabel={'Tap me!'} onPress={this._onPress}> | ||
<View style={styles.button}> | ||
<Text style={styles.buttonText}>Press me!</Text> | ||
</View> | ||
</TouchableOpacity>``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The triple backtick here needs to be on a newline 😄 |
||
|
||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so it would default to it but because we specify the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct |
||
|
||
#### accessibilityTraits | ||
|
||
Accessibility traits tell a person using VoiceOver what kind of element they have selected. Is this element a label? A button? A header? These questions are answered by `accessibilityTraits`. | ||
|
||
To use, set the `accessibilityTraits` property to one of (or an array of) accessibility trait strings: | ||
|
||
* **none** Used when the element has no traits. | ||
* **button** Used when the element should be treated as a button. | ||
* **link** Used when the element should be treated as a link. | ||
* **header** Used when an element acts as a header for a content section (e.g. the title of a navigation bar). | ||
* **search** Used when the text field element should also be treated as a search field. | ||
* **image** Used when the element should be treated as an image. Can be combined with button or link, for example. | ||
* **selected** Used when the element is selected. For example, a selected row in a table or a selected button within a segmented control. | ||
* **plays** Used when the element plays its own sound when activated. | ||
* **key** Used when the element acts as a keyboard key. | ||
* **text** Used when the element should be treated as static text that cannot change. | ||
* **summary** Used when an element can be used to provide a quick summary of current conditions in the app when the app first launches. For example, when Weather first launches, the element with today's weather conditions is marked with this trait. | ||
* **disabled** Used when the control is not enabled and does not respond to user input. | ||
* **frequentUpdates** Used when the element frequently updates its label or value, but too often to send notifications. Allows an accessibility client to poll for changes. A stopwatch would be an example. | ||
* **startsMedia** Used when activating an element starts a media session (e.g. playing a movie, recording audio) that should not be interrupted by output from an assistive technology, like VoiceOver. | ||
* **adjustable** Used when an element can be "adjusted" (e.g. a slider). | ||
* **allowsDirectInteraction** Used when an element allows direct touch interaction for VoiceOver users (for example, a view representing a piano keyboard). | ||
* **pageTurn** Informs VoiceOver that it should scroll to the next page when it finishes reading the contents of the element. | ||
|
||
#### onAccessibilityTap | ||
|
||
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. | ||
|
||
#### onMagicTap | ||
|
||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any rule for what component we should add this handler to? Should it be on our app root or anywhere? What happens if we have two of them? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When you perform the magic tap gesture, it starts at the selected element and bubbles up through the parents to see if anyone implements the magic tap gesture. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes total sense, thanks! Might be helpful to add that to the docs here! |
||
|
||
### Testing VoiceOver Support | ||
|
||
To enable VoiceOver, go to the Settings app on your iOS device. Tap General, then Accessibility. There you will find many tools that people use to use to make their devices more usable, such as bolder text, increased contrast, and VoiceOver. | ||
|
||
To enable VoiceOver, tap on VoiceOver under "Vision" and toggle the switch that appears at the top. | ||
|
||
At the very bottom of the Accessibility settings, there is an "Accessibility Shortcut". You can use this to toggle VoiceOver by triple clicking the Home button. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing "s"