JSPM

react-aria-hooks

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q11962F
  • License MIT

Accessible React hooks for ARIA live regions, focus traps, and more.

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 via aria-live regions
  • ♿️ 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 drawers
  • useVisuallyHidden – visually hide content but expose it to assistive tech
  • useSkipLink – add skip-to-content links
  • And more!

πŸ“„ License

MIT Β© Andrii Tsapko