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 🙏

© 2025 – Pkg Stats / Ryan Hefner

dialog-lite

v2.0.0

Published

DialogLite is designed to control a dialog box (modal window) on a web page, providing the functionality to open, close and apply custom styles through a simple interface.

Readme

npm GitHub package version NPM Downloads

Install

yarn add dialog-lite

Import

import { DialogLite } from 'dialog-lite';

or

import { initDialogLite } from 'dialog-lite';

CSS

import 'dialog-lite/dialog-lite.css';

or

@import "dialog-lite/dialog-lite.css";

Usage

const dialogLite = initDialogLite({
  closingButton: true,
  closingBackdrop: true,
  injectCss: false, // since we import CSS separately
});

button.addEventListener('click', () => {
  dialogLite.open({
    stylingClass: 'dialog-lite--first-window',
  });
});

Classic (class) API

const dialogLite = new DialogLite({ closingButton: true, closingBackdrop: true });
dialogLite.init();

Markup

Use hidden for the initial hidden state. Do not rely on style="display:none" (the library toggles via hidden).

<div class="dialog-lite dialog-lite--out" hidden aria-hidden="true">
  <div class="dialog-lite__backdrop"></div>
  <div class="dialog-lite__container">
    <div class="dialog-lite__container-inner">
      <button class="dialog-lite-close-button" type="button" aria-label="Close" tabindex="0"></button>
      <div>Your content</div>
    </div>
  </div>
</div>

Options

| Option | Type | Default | Description | |:--|:--:|:--:|:--| | closingButton | boolean | false | Enables close on .dialog-lite-close-button click. | | closingBackdrop | boolean | false | Enables close on .dialog-lite__backdrop click. | | dialog | HTMLElement \| string | '.dialog-lite' | Dialog root element or selector. | | mainContent | HTMLElement \| string \| null | '#main-content' | Element/selector to set aria-hidden on while open. Set null to disable. | | closeButtonSelector | string | '.dialog-lite-close-button' | Close button selector inside dialog. | | backdropSelector | string | '.dialog-lite__backdrop' | Backdrop selector inside dialog. | | debounceMs | number | 500 | Debounce window for open/close. | | hideDelayMs | number | 500 | Delay before setting hidden on close (should match CSS). | | focusOnOpenSelector | string | '[tabindex="0"]' | Element to focus when opened. | | lockScroll | boolean | true | Locks page scroll while open. | | trapFocus | boolean | true | Enables simple focus trap (Tab cycling) while open. | | emitEvents | boolean | true | Emits dialog-lite:open / dialog-lite:close on the dialog element. |

API

| API | Parameters | Description | |:--|:--|:--| | new DialogLite(options) | DialogLiteOptions | Creates controller instance. | | init() | — | Attaches listeners and resolves DOM elements. | | open() | { stylingClass?: string } | Opens dialog, toggles classes/attributes, focuses inside. | | close() | — | Closes dialog, restores focus, sets hidden after hideDelayMs. | | destroy() | — | Removes listeners and clears timers. | | createDialogLite(options) | DialogLiteOptions | Functional constructor (returns { init, open, close, destroy }). | | initDialogLite(options) | DialogLiteOptions & { injectCss?: boolean; cssText?: string; cssTarget?: Document \| ShadowRoot } | Creates instance, optionally injects CSS, calls init(), returns controller. | | injectDialogLiteCss() | { target?: Document \| ShadowRoot; cssText?: string; id?: string } | Injects <style> with default/minified CSS (or custom cssText). | | dialogLiteCssText | — | Minified CSS string (useful for Shadow DOM). |

Events

| Event | Description | |:--|:--| | dialog-lite:open | Dispatched on the dialog element after open() (detail includes stylingClass). | | dialog-lite:close | Dispatched on the dialog element after close(). |

License

dialog-lite is released under MIT license