可访问性

ReactXP 提供了一种跨平台实现无障碍功能的通用方法。

屏幕阅读器是一种为视障用户提供的辅助技术。它允许用户通过聚焦可操作组件并宣布这些组件的用途来浏览应用程序。

ReactXP 组件 ViewButtonGestureViewTextInput 实现了一组通用的无障碍相关属性,如下所述。

还提供了附加的 无障碍 API,用于以编程方式调用屏幕阅读器来宣布事件。

无障碍特性在适当情况下会覆盖默认的屏幕阅读器行为。例如,Button 的默认行为是在标签末尾附加文本“按钮”。在大多数情况下,默认特性提供了所需行为,但有时提供额外信息给屏幕阅读器会很有用。

类型

export enum ImportantForAccessibility {
    // Platform decides which views are important for accessibility and brings
    // the screen reader focus on those views
    Auto,

    // Groups all subviews under the view, allowing the screen reader to focus
    // just this view; if the accessibilityLabel is specified, it is announced;
    // otherwise, the labels of its children are used
    Yes,

    // Tells the screen reader that it can focus the subviews of this view
    No,

    // Hides the view and its subviews from the screen reader
    NoHideDescendants
}

属性

// Array of strings that will be added as custom actions on iOS
accessibilityActions?: string[] = undefined;

// Label that is read by the screen reader
accessibilityLabel?: string = undefined;

// Overrides or augments default screen reader behavior
accessibilityTraits?: AccessibilityTrait | AccessibilityTrait[] = undefined;

// Screen reader focus behavior
importantForAccessibility?: ImportantForAccessibility = Auto;

// Callback function invoked for accessibility action events
onAccessibilityAction?: (e: SyntheticEvent) => void;

// Keyboard tab order
tabIndex?: number = undefined; // web only

// Used to define the current value for a range widget such as a slider, spinbutton or progressbar
ariaValueNow?: number = undefined; // web only