New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pure-modal

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pure-modal

A lightweight, accessible, vanilla JavaScript modal component

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Pure-modal

A lightweight, accessible, vanilla JavaScript modal component.

Demo and documentation

https://romanslonov.github.io/pure-modal/

Basic usage

1. Add modal markup on your page and give it unique ID.
<div class="modal" id="modal1" role="dialog" aria-labelledby="modal-1" aria-describedby="basic-modal" tabindex="-1" style="display: none;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Modal title 1</h5>
                <button type="button" class="modal-close" data-dismiss="modal" aria-label="Close">
                    <svg width="16" height="16" viewBox="0 0 40 40">
                        <path stroke-linecap="round" class="close-x" d="M 10,10 L 30,30 M 30,10 L 10,30" stroke="#000" fill="transparent" stroke-width="5"></path>
                    </svg>
                </button>
            </div>
            <div class="modal-body">
                Content of modal 1
            </div>
            <div class="modal-footer">
                <div class="mr-xs">
                    <button data-dismiss="modal" aria-label="Close">Close</button>
                </div>
                <button>Save changes</button>
            </div>
        </div>
    </div>
</div>
2. Init modal instance and pass unqiue ID of your modal.
const modal1 = new Modal('modal1');
modal1.init();
3. Add trigger to open the modal.
<button data-toggle="modal" data-target="modal1">Modal 1</button>

Done! 🎉

API

Options

NametypeDefaultDescription
transitionBooleantrueInitialize PureModal instance. Add event listeners.
beforeOpenFunctionnullA callback that will be called before opening the modal.
onOpenFunctionnullA callback that will be called after the modal is fully opened.
beforeCloseFunctionnullA callback that will be called before closing the modal.
onCloseFunctionnullA callback that will be called after the modal is fully closed.

Methods

NameDescription
init()Initialize PureModal instance. Add event listeners.
destroy()Destroy all event listeners. Useful when building SPA.
open()Call to open modal manually.
close()Call to close modal manually.

Keywords

FAQs

Package last updated on 14 Apr 2019

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