npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

a11y-alert-dialog

v0.1.2

Published

Accessibility-first alert and dialog library that works without a mouse

Readme

Accessible Alert

a11y-alert-dialog

npm version npm downloads

Accessibility-first alert & dialog library that works without a mouse.

Accessible Alert is a framework-agnostic JavaScript library for displaying alert, confirm, and prompt dialogs with accessibility-first (a11y-first) design.

If you can use a keyboard, you can use this library.


✨ Why does this library exist?

Most alert/modal libraries:

  • Prioritize visuals and animations
  • Treat accessibility as an afterthought
  • Break keyboard navigation and screen readers easily

👉 Accessible Alert is built the opposite way:

Accessibility is the foundation, not a feature added later.


✅ Accessibility Guarantees (A11Y Contract)

This library always guarantees:

  • No mouse required
  • Fully usable with keyboard only (Tab / Enter / Esc)
  • Correct focus management at all times
  • Focus is never lost after closing dialogs
  • Proper screen reader announcements
  • No auto-close behaviors that steal control from users

Standards:

  • WCAG 2.1 AA
  • WAI-ARIA Authoring Practices (Dialog)

📦 Installation

NPM

npm install a11y-alert-dialog

CDN

<script src="https://www.npmjs.com/package/a11y-alert-dialog"></script>

🚀 Basic Usage

Alert

await alert("Saved successfully")

Confirm

const ok = await confirm({
  title: "Delete user",
  description: "This action cannot be undone",
  danger: true
})

if (ok) {
  deleteUser()
}

Prompt

const name = await prompt({
  title: "Your name",
  placeholder: "Enter your name"
})

⌨️ Keyboard Behavior (Always Enabled)

| Key | Action | |----|-------| | Tab | Move forward within the dialog | | Shift + Tab | Move backward | | Enter | Confirm primary action | | Esc | Cancel / Close dialog |

Keyboard support cannot be disabled.


🧠 How Accessibility Is Handled

Focus Management

  • Saves the currently focused element before opening
  • Automatically moves focus into the dialog
  • Restores focus to the original element after closing

Focus Trap

  • Tab navigation is trapped inside the dialog
  • Focus never escapes to the background
  • No CSS hacks or pointer-event tricks

Screen Reader Support

  • Uses role="dialog" or role="alertdialog"
  • Proper aria-labelledby and aria-describedby
  • Dialog content is announced immediately on open

🧩 API Design Principles

  • Promise-based API
  • No callbacks
  • No configuration options that can break accessibility
  • No custom HTML injection for critical controls
await confirm({ title: "Are you sure?" })

If an API allows breaking accessibility, the API is wrong.


❌ What This Library Does NOT Support

To protect accessibility, this library intentionally does NOT support:

  • Auto-close timers
  • Disabling focus trapping
  • Custom button HTML
  • Complex animations
  • Theme systems
  • Toast-style notifications

👉 If you want flashy UI effects, this library is not for you.


🧪 Testing philosophy

This library intentionally does not use automated browser testing.

Accessibility behavior such as keyboard navigation, focus management, and screen reader interaction cannot be reliably validated in headless or simulated environments.

Instead, this project relies on:

  • Manual keyboard-only testing
  • Screen reader testing (NVDA / VoiceOver)
  • A strict accessibility contract defined in A11Y.md

This approach reflects real-world accessibility usage more accurately than flaky automated tests.


🎯 When Should You Use This Library?

✔ Internal tools
✔ Admin dashboards
✔ SaaS products
✔ Enterprise / Government / Fintech
✔ Any project where accessibility is a real requirement


📄 License

MIT


💬 Philosophy

“If you can use a keyboard, you can use this alert.”