|
| 1 | +--- |
| 2 | +id: accessibilityinfo |
| 3 | +title: AccessibilityInfo |
| 4 | +officialDoc: https://reactnative.dev/docs/accessibilityinfo |
| 5 | +--- |
| 6 | + |
| 7 | +## Types |
| 8 | + |
| 9 | +### `announcementResult` |
| 10 | + |
| 11 | +Passed to the handler of the `` `announcementFinished `` event. |
| 12 | + |
| 13 | +```rescript |
| 14 | +type announcementResult = { |
| 15 | + announcement: string, |
| 16 | + success: bool, |
| 17 | +} |
| 18 | +``` |
| 19 | + |
| 20 | +where `announcement` is the string announced by the screen reader and `success` |
| 21 | +is a `bool` indicating whether the announcement was successfully made. |
| 22 | + |
| 23 | +## Methods |
| 24 | + |
| 25 | +### `isBoldTextEnabled` |
| 26 | + |
| 27 | +_iOS only_ |
| 28 | + |
| 29 | +To query whether bold text is currently enabled. Promise resolves to `true` when |
| 30 | +bold text is enabled and `false` otherwise. |
| 31 | + |
| 32 | +```rescript |
| 33 | +isBoldTextEnabled: unit => Js.Promise.t(bool) |
| 34 | +``` |
| 35 | + |
| 36 | +### `isGrayscaleEnabled` |
| 37 | + |
| 38 | +_iOS only_ |
| 39 | + |
| 40 | +To query whether grayscale is currently enabled. Promise resolves to `true` when |
| 41 | +grayscale is enabled and `false` otherwise. |
| 42 | + |
| 43 | +```rescript |
| 44 | +isGrayscaleEnabled: unit => Js.Promise.t(bool) |
| 45 | +``` |
| 46 | + |
| 47 | +### `isInvertColorsEnabled` |
| 48 | + |
| 49 | +_iOS only_ |
| 50 | + |
| 51 | +To query whether invert colors is currently enabled. Promise resolves to `true` |
| 52 | +when invert colors is enabled and `false` otherwise. |
| 53 | + |
| 54 | +```rescript |
| 55 | +isInvertColorsEnabled: unit => Js.Promise.t(bool) |
| 56 | +``` |
| 57 | + |
| 58 | +### `isReduceMotionEnabled` |
| 59 | + |
| 60 | +To query whether reduce motion is currently enabled. Promise resolves to `true` |
| 61 | +when reduce motion is enabled and `false` otherwise. |
| 62 | + |
| 63 | +```rescript |
| 64 | +isReduceMotionEnabled: unit => Js.Promise.t(bool) |
| 65 | +``` |
| 66 | + |
| 67 | +### `isReduceTransparencyEnabled` |
| 68 | + |
| 69 | +_iOS only_ |
| 70 | + |
| 71 | +To query whether reduce transparency is currently enabled. Promise resolves to |
| 72 | +`true` when reduce transparency is enabled and `false` otherwise. |
| 73 | + |
| 74 | +```rescript |
| 75 | +isReduceTransparencyEnabled: unit => Js.Promise.t(bool) |
| 76 | +``` |
| 77 | + |
| 78 | +### `isScreenReaderEnabled` |
| 79 | + |
| 80 | +To query whether screen reader is currently enabled. Promise resolves to `true` |
| 81 | +when screen reader is enabled and `false` otherwise. |
| 82 | + |
| 83 | +```rescript |
| 84 | +isScreenReaderEnabled: unit => Js.Promise.t(bool) |
| 85 | +``` |
| 86 | + |
| 87 | +### `setAccessibilityFocus` |
| 88 | + |
| 89 | +To set accessibility focus to a React component, identified by its `nodeHandle`. |
| 90 | +On Android, this is equivalent to |
| 91 | +`UIManager.sendAccessibilityEvent(reactTag, UIManager.AccessibilityEventTypes.typeViewFocused)`; |
| 92 | + |
| 93 | +```rescript |
| 94 | +setAccessibilityFocus: NativeTypes.nodeHandle => unit |
| 95 | +``` |
| 96 | + |
| 97 | +### `announceForAccessibility` |
| 98 | + |
| 99 | +To post a string to be announced by the screen reader. |
| 100 | + |
| 101 | +```rescript |
| 102 | +announceForAccessibility: string => unit |
| 103 | +``` |
| 104 | + |
| 105 | +### `addEventListener` |
| 106 | + |
| 107 | +Add an event handler. |
| 108 | + |
| 109 | +```rescript |
| 110 | +addEventListener: [ |
| 111 | + | #boldTextChanged(bool => unit) |
| 112 | + | #grayscaleChanged(bool => unit) |
| 113 | + | #invertColorsChanged(bool => unit) |
| 114 | + | #reduceMotionChanged(bool => unit) |
| 115 | + | #screenReaderChanged(bool => unit) |
| 116 | + | #reduceTransparencyChanged(bool => unit) |
| 117 | + | #announcementFinished(announcementResult => unit) |
| 118 | + ] => unit |
| 119 | +``` |
| 120 | + |
| 121 | +Supported events: |
| 122 | + |
| 123 | +- `boldTextChanged(bool => unit)`: _iOS only_. Fires when state of the bold text |
| 124 | + toggle changes. The argument to the event handler is a `bool` which is `true` |
| 125 | + when bold text is enabled and `false` otherwise. |
| 126 | +- `grayscaleChanged(bool => unit)`: _iOS only_. Fires when state of the gray |
| 127 | + scale toggle changes. The argument to the event handler is a `bool` which is |
| 128 | + `true` when gray scale is enabled and `false` otherwise. |
| 129 | +- `invertColorsChanged(bool => unit)`: _iOS only_. Fires when state of the |
| 130 | + invert colors toggle changes. The argument to the event handler is a `bool` |
| 131 | + which is `true` when invert colors is enabled and `false` otherwise. |
| 132 | +- `reduceMotionChanged(bool => unit)`: Fires when state of the reduce motion |
| 133 | + toggle changes. The argument to the event handler is a `bool` which is `true` |
| 134 | + when reduce motion is enabled (or when "Transition Animation Scale" in |
| 135 | + "Developer options" is "Animation off") and `false` otherwise. |
| 136 | +- `screenReaderChanged(bool => unit)`: Fires when state of the screen reader |
| 137 | + changes. The argument to the event handler is a `bool` which is `true` when a |
| 138 | + screen reader is enabled and `false` otherwise. |
| 139 | +- `reduceTransparencyChanged(bool => unit)`: _iOS only_. Fires when state of the |
| 140 | + reduce transparency toggle changes. The argument to the event handler is a |
| 141 | + `bool` which is `true` when reduce transparency is enabled and `false` |
| 142 | + otherwise. |
| 143 | +- `announcementFinished(announcementResult => unit)`: _iOS only_. Fires when the |
| 144 | + screen reader has finished making an announcement. The argument to the event |
| 145 | + handler is of type [`announcementResult`](#announcementResult). |
| 146 | + |
| 147 | +### `removeEventListener` |
| 148 | + |
| 149 | +To remove an event handler. |
| 150 | + |
| 151 | +See [`addEventListener`](#addEventListener) for more details on supported |
| 152 | +events. |
0 commit comments