0.0.2 • Published 3 years ago
use-read-alert v0.0.2
use-read-alert
A callback hook to read assertive alert by the screen reader.
Background
How to use
Installs the provider component. The provider component is required to use the useReadAlert hook.
import { UseReadAlertProvider } from 'use-read-alert';
React.createRoot(document.getElementById('root')).render(
<UseReadAlertProvider>
<App />
</UseReadAlertProvider>
);Then, in your React component, calls the callback function to read the alert message.
import { useReadAlert } from 'use-read-alert';
const MyComponent = () => {
const readAlert = useReadAlert();
readAlert('Hello, World!');
// ...
};API
function UseReadAlertProvider(PropsWithChildren<{
alertClassName?: string;
}>);
function useReadAlert(): (message: string) => void;By default, the alert role will be hidden using CSS. If you prefer to hide it using your own CSS, you can provide an alertClassName.
Behaviors
Contributions
Like us? Star us.
Want to make it better? File us an issue.
Don't like something you see? Submit a pull request.
0.0.3-main.c4cac7c
3 years ago
0.0.2
3 years ago
0.0.1-main.720cb21
3 years ago
0.0.1-main.646a91d
3 years ago
0.0.1-main.d12b81f
3 years ago
0.0.1-main.2e81e72
3 years ago
0.0.1-main.8e0db13
3 years ago
0.0.1-main.704458
3 years ago
0.0.1-main.c368b19
3 years ago
0.0.1-main.7c2924b
3 years ago
0.0.1-main.13b0470
3 years ago
0.0.1-main.7f98760
3 years ago
0.0.1-main.6389e66
3 years ago
0.0.1-main.d31833e
3 years ago
0.0.1-main.2888d3f
3 years ago
0.0.1-main.7abd93e
3 years ago
0.0.1
3 years ago
0.0.1-main.5991230
3 years ago
0.0.1-main.a4c078a
3 years ago
0.0.1-main.c44c3e0
3 years ago
0.0.1-main.9a6114c
3 years ago
0.0.1-main.742f40a
3 years ago
0.0.1-main.f007ba3
3 years ago
0.0.1-main.98c2dbd
3 years ago