Magnit Modal Demo

A zero-dependency, vanilla javascript (es6) modal web component.

Code examples can be found in the dev console by inspecting the script tags in each section.


Simple Modal

A classic example


Modal Themes

A small group of themes included in the component for status messaging. Also, simple css variables to customize the theme.

  • Custom

Ask Modal

Get Selected Choice

Await the ask() method to get the method of closing as a result.

Choice:

Prevent Close on Error

Pass in a callback function into the ask(myCallback) method to validate whether or not a modal will be allowed to close.

Choice:

Nested Modals

One modal opening another, and interacting with the second modal's choice.


Dynamic Message

Set the content of the modal dynamically.


Open Form Modal

Await the submitForm() helper method to submit forms and await their result before closing the modal.