Package Exports
- react-aria-hooks
- react-aria-hooks/dist/index.js
- react-aria-hooks/dist/index.mjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-aria-hooks) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
react-aria-hooks
A lightweight set of accessible React hooks (a11y) for building inclusive, screen readerβfriendly web applications.
π£ What is useAnnouncer?
Screen readers do not automatically announce dynamic updates like βMessage sentβ or β7 results found.β Unless focus moves or an ARIA live region is used, these changes can go unnoticed.
The useAnnouncer hook enables you to programmatically send messages to screen readers β without disrupting the layout or moving focus.
β¨ Features
- π
useAnnouncerβ announce messages viaaria-liveregions - βΏοΈ Follows accessibility best practices (WAI-ARIA)
- βοΈ Works in any React project (TypeScript-ready, zero dependencies)
- π§Ή Composable, tree-shakable, and easy to integrate
π¦ Installation
npm install react-aria-hooksπ§ Quick Start
import { useAnnouncer } from "react-aria-hooks";
import { useState } from "react";
function SearchResults() {
const announce = useAnnouncer();
const [results, setResults] = useState(0);
const handleSearch = () => {
const newResults = Math.floor(Math.random() * 10);
setResults(newResults);
announce(`${newResults} results found`);
};
return (
<div>
<button onClick={handleSearch}>Search</button>
<p>Results: {results}</p>
</div>
);
}π‘ When to Use useAnnouncer
Use it when:
- Content updates without a focus change
- Screen readers might miss visual changes
- You want to notify users non-visually
β Examples
announce("Message sent successfully"); // Toasts or alerts
announce("Email field is required"); // Form errors
announce("Sort by: Price"); // Custom selects
announce("Data loaded"); // Async events
announce("7 results found"); // Search
announce("Page 2 of 10"); // Paginationπ οΈ Coming Soon
More accessible hooks are on the way:
useFocusTrapβ trap focus inside modals or drawersuseVisuallyHiddenβ visually hide content but expose it to assistive techuseSkipLinkβ add skip-to-content links- And more!
π License
MIT Β© Andrii Tsapko