Skip to main content

Pressable

The Pressable component is an enhancement of the React Native Pressable component, with a focus on improving accessibility.

import { Pressable } from 'react-native-ama';

<Pressable accessibilityRole="button" accessibilityLabel="I'm pressable!">
<Text>I'm pressable</Text>
</Pressable>;

Accessibility improvements

In comparison to the default React Native component, this customized component:

  • Forces the use of accessibilityRole and accessibilityLabel
  • accessibilityState has been removed as its states busy, checked, selected, expanded are exposed as a property
  • Performs a Minimum Size check
  • Performs a contrast checker between its background color and its children color
Dev mode only!

Runtime checks are only performed when __DEV__ is set to true

accessibilityRole

The accessibilityRole property is used by the screen reader to announce the kind of element focused on. If the property is omitted, the user might have little to no clue what could happen if the element is triggered.

Check the accessibility role guidelines for more info.

accessibilityLabel

The accessibilityLabel property is the first thing announced by the screen reader when the elements gain the focus; then, it announces its role. If the property is omitted, the user might have little to no clue what could happen if the element is triggered.

Check the accessibility label guidelines for more info.

aria-busy

Indicates an element is being modified and that assistive technologies may want to wait until the changes are complete before informing the user about the update.1

TypeDefault
booleanfalse

aria-checked

Indicates the state of a checkable element. This field can either take a boolean or the "mixed" string to represent mixed checkboxes.

TypeDefault
boolean, 'mixed'false

aria-disabled

Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.

TypeDefault
booleanfalse

aria-expanded

Indicates whether an expandable element is currently expanded or collapsed.

TypeDefault
booleanfalse

aria-selected

Indicates whether a selectable element is currently selected or not.

TypeDefault
booleanfalse

Contrast checker

The component performs a contrast check between its background colour and the children's foreground when in dev mode.

info

AMA does also perform a contrast check on disabled button, as a poor contrast can make them hard to read.

Minimum size

The component uses the onLayout prop to perform the minium size check.

External resources

Footnotes

  1. https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-busy