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

angular-accessible-modal

v0.2.4

Published

An accessible, flexible modal wrapper component for Angular 2+

Readme

Angular Accessible Modal

An Angular modal wrapper component that aims to be fully accessible. Keyboard navigation is trapped within the modal while it is open, and the modal can be closed by pressing escape. Styles are customizable. Currently supports rendering one modal at a time.

Version 0.2.2 fixes a critical defect that prevented the body of the page from scrolling when the modal was closed. Version 0.1.11 fixes a bug that prevented the modal from closing when clicking the backdrop.

Adding to Project

In the relevant module file (e.g., app.module.ts):

import { AccessibleModalModule } from 'angular-accessible-modal';
...
@NgModule({
  imports: [
    AccessibleModalModule // include in the list of module imports
  ]
})

Implementing the Modal

Within your component template:

<button
	acmToggleAccessibleModal // use this directive to trigger modal
	modalId="my-modal"
>
	Open modal
</button>

<acm-accessible-modal modalId="my-modal">
	// use this component tag to wrap any content
	// make sure the modalId input matches
	<h2>My Modal</h2>

	<button
		acmToggleAccessibleModal // modalId input not necessary to close modal
		autofocus
	>
		Close modal
	</button>
</acm-accessible-modal>

Note: for accessibility, developers should take care to programatically focus the first interactable element of their modal content. Options include the autofocus attribute for certain HTML native elements, or placing the modal content inside a separate component and focusing the element in the ngAfterViewInit lifecycle hook. See guidance here: https://www.w3.org/TR/wai-aria-practices-1.2/#dialog_modal

Toggle the Modal Programmatically

Note that the directive is recommmended when a user interaction with a page element (e.g., click) opens the modal, since that will ensure that element retains focus when the modal closes. Another option is to pass an ElementRef representing the element as a second argument to the toggleModal method.

Within your component's .ts file:

import { AccessibleModalService } from 'angular-accessible-modal';
...
constructor (private accModalService: AccessibleModalService) {}
...
toggleModal() {
	this.accModalService.toggleModal('my-modal');
	// modalId argument necessary for opening modal, optional for closing modal
}

Customizing Styles

Use the overlayStyles input to adjust the appearance of the background. Example:

<acm-accessible-modal
	[overlayStyles]="{background: 'rgba(0, 0, 0, 0.5)'}"
>

Use the modalStyles input to adjust the appearance of the modal itself. For example, if you want the modal to appear near the top of the window, rather than centered vertically:

<acm-accessible-modal
	[modalStyles]="{'align-self': 'inherit', 'margin-top': '20px'}"
>

By default, the modal is centered vertically and horizontally using:

{
	align-self: center; // the parent is a flex container
	margin: 0 auto;
}

Enabling Animations

When the modal appears, a fade in and/or a slide down effect can be enabled. Similarly, when the modal exits, a fade out and/or a slide up effect can be enabled. Example usage:

<acm-accessible-modal
  modalId="category-modal"
  [entranceAnimations]="['fadeIn', 'slideDown']" // default: []
  entranceDuration="300ms" // default: 250ms
  [exitAnimations]="['fadeOut', 'slideUp']" // default: []
  exitDuration="100ms" // default: 250ms
>