Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dialog-lite

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dialog-lite

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.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
70
Maintainers
0
Weekly downloads
 
Created
Source

dialog-lite

npm GitHub package version NPM Downloads

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.

750B gzipped

Demo


Install

yarn add dialog-lite

Import

import DialogLite from 'dialog-lite';

CSS

@import "dialog-lite/dist/";

if your bundler supports SCSS

@import "dialog-lite/src/";

Usage

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

dialogLite.init();

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

Options

OptionTypeDefaultDescription
closingButtonbooleanfalseWhen set to true, enables the close button functionality in the dialog. The dialog can be closed by clicking the close button.
closingBackdropbooleanfalseWhen set to true, enables closing the dialog by clicking on the backdrop.

API

MethodParametersDescription
initNoneInitializes the dialog, setting up event listeners for close button, backdrop click, and escape key based on the provided options.
open{ stylingClass?: string }
Default: { stylingClass: '' }
Opens the dialog, applying the specified styling class. Focuses on the first element inside the dialog with tabindex="0", and stores the previously focused element.
closeNoneCloses the dialog, restoring focus to the previously focused element. Adds the class for closing animation and optionally delays removal of the class.

Events

MethodDescription
click (Close Button)Triggered when the close button is clicked, closing the dialog if closingButton option is enabled.
click (Backdrop)Triggered when the backdrop is clicked, closing the dialog if closingBackdrop option is enabled.
keydown (Escape key)Triggered when the Escape key is pressed, closing the dialog.

License

dialog-lite is released under MIT license

Keywords

FAQs

Package last updated on 18 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc