Skip to main content

AccessibilityInfo

Types​

announcementResult​

Passed to the handler of the #announcementFinished event.

type announcementResult = {
announcement: string,
success: bool,
}

where announcement is the string announced by the screen reader and success is a bool indicating whether the announcement was successfully made.

Methods​

Query methods​

Each of these returns promise<bool>:

MethodNotes
isBoldTextEnablediOS
isGrayscaleEnablediOS
isInvertColorsEnablediOS
isReduceMotionEnabled
isReduceTransparencyEnablediOS
isScreenReaderEnabled
isHighTextContrastEnabled
isDarkerSystemColorsEnabled
isAccessibilityServiceEnabled
prefersCrossFadeTransitions
isScreenReaderEnabled: unit => promise<bool>

getRecommendedTimeoutMillis​

getRecommendedTimeoutMillis: float => promise<float>

announceForAccessibility​

announceForAccessibility: string => unit
announceForAccessibilityWithOptions: (string, {queue?: bool}) => unit

setAccessibilityFocus​

@deprecated Prefer sendAccessibilityEvent with #focus.

setAccessibilityFocus: NativeTypes.nodeHandle => unit

sendAccessibilityEvent​

sendAccessibilityEvent: (
Ref.t<DOMAPI.element<'nativeElement>>,
[#click | #focus | #viewHoverEnter | #windowStateChange],
) => unit

addEventListener​

Add an event handler. Returns an EventSubscription — call .remove() to unsubscribe.

addEventListener: [
| #boldTextChanged(bool => unit)
| #grayscaleChanged(bool => unit)
| #invertColorsChanged(bool => unit)
| #reduceMotionChanged(bool => unit)
| #screenReaderChanged(bool => unit)
| #reduceTransparencyChanged(bool => unit)
| #highTextContrastChanged(bool => unit)
| #darkerSystemColorsChanged(bool => unit)
| #accessibilityServiceChanged(bool => unit)
| #announcementFinished(announcementResult => unit)
] => EventSubscription.t
React.useEffect0(() => {
let sub = AccessibilityInfo.addEventListener(#screenReaderChanged(enabled => {
Console.log(enabled)
}))
Some(() => sub->EventSubscription.remove)
})