A one day, single-track online event celebrating the future of cross-platform app development

DocsPluginsCLI

@capacitor/screen-reader

The Screen Reader API provides access to TalkBack/VoiceOver/etc. and provides simple text-to-speech capabilities for visual accessibility.

Install

npm install @capacitor/screen-reader
npx cap sync

Example

import { ScreenReader } from '@capacitor/screen-reader';

ScreenReader.addListener('screenReaderStateChange', ({ value }) => {
  console.log(`Screen reader is now ${value ? 'on' : 'off'}`);
});

const checkScreenReaderEnabled = async () => {
  const { value } = await ScreenReader.isEnabled();

  alert('Voice over enabled? ' + value);
};

const sayHello = async () => {
  await ScreenReader.speak({ value: 'Hello World!' });
};

API

isEnabled()

isEnabled() => Promise<{ value: boolean; }>

Whether a Screen Reader is currently active.

This method is not supported on web (it is not possible to detect Screen Readers).

Returns: Promise<{ value: boolean; }>

Since: 1.0.0


speak(…)

speak(options: SpeakOptions) => Promise<void>

Text-to-Speech functionality.

This function will only work if a Screen Reader is currently active.

On web, browsers must support the SpeechSynthesis API, or this method will throw an error.

For more text-to-speech capabilities, please see the Capacitor Community Text-to-Speech plugin.

Param Type
options SpeakOptions

Since: 1.0.0


addListener(‘screenReaderStateChange’, …)

addListener(eventName: 'screenReaderStateChange', listener: StateChangeListener) => PluginListenerHandle

Add a listener

This method is not supported on web (it is not possible to detect Screen Readers).

Param Type
eventName 'screenReaderStateChange'
listener StateChangeListener

Returns: PluginListenerHandle

Since: 1.0.0


removeAllListeners()

removeAllListeners() => void

Remove all the listeners that are attached to this plugin.

Since: 1.0.0


Interfaces

SpeakOptions

Prop Type Description Since
value string The text to speak. 1.0.0
language string The language to speak the text in, as its ISO 639-1 Code (e.g.: “en”). This option is only supported on Android. 1.0.0

PluginListenerHandle

Prop Type
remove () => void

ScreenReaderState

Prop Type Description Since
value boolean Whether a Screen Reader is currently active. 1.0.0

Type Aliases

StateChangeListener

(state: ScreenReaderState): void

Previous
<- Push Notifications
Next
Share ->
Contribute ->