UNPKG

react-announce-a11y

Version:

Used to have the screen reader announce messages to the user. Great for things like searches, filtering, loading, and error messages.

36 lines (35 loc) 1.32 kB
import * as React from 'react'; export declare type AnnounceMethod = (message: string) => void; export interface AnnounceProps { announceMessage?: string; /** * Only used for the prop.announceMessage way of passing the message. * This is especially useful for giving messages from searches/filters. */ debounceDelay?: number; politeness?: 'polite' | 'assertive'; /** * This gives back a direct function for supplying an announcement for the screen reader. * This does not have any delay built into it. * If a new message comes in, the first may be cut off. */ setAnnounceMethod?: (announceMethod: AnnounceMethod) => void; } /** * Give an announcement to the screen reader to read. * Can be done via a prop or via a direct method using the setAnnounceMethod prop. */ export declare class ReactAnnounce extends React.Component<AnnounceProps, { message: string; }> { state: { message: string; }; componentDidMount(): void; componentDidUpdate(prevProps: AnnounceProps): void; debounceDelay: () => number; debouncePropMessage: (() => void) & import("lodash").Cancelable; updateMessage: (message?: string | undefined) => void; announceMethod: AnnounceMethod; render(): JSX.Element; }