Tiny Flexible Modal & Dialog Plugin With jQuery - flexModal

Tiny Flexible Modal & Dialog Plugin With jQuery - flexModal
File Size: 8.76 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT

flexModal is an alternative to the jQuery tinyLayer plugin that helps you create flexible, customizable, AJAX-enabled and clean looking modal windows for alerts, notifications, dialog boxes and many more.

Basic usage:

1. Include the stylesheet jquery.flex-modal.css in the <head> section of the document, and the JavsScript file jquery.flex-modal.js after loading jQuery as follows.

<link rel="stylesheet" href="jquery.flex-modal.css">
<script src="//code.jquery.com/jquery-3.0.0.min.js"></script>
<script src="jquery.flex-modal.js"></script>

2. Create a simple modal dialog.

<button type="button" data-modal-target="#modal-1">Lanuch</button>
<div id="modal-1" class="modal-1 flex-modal-hide">
  <p>Just a text to display</p>

3. Create a confirmation dialog which is not closeable via close button, overlay or ESC key.

<button type="button" data-modal-target="#modal-2">Lanuch</button>
<div id="modal-2" class="modal-2 flex-modal-hide" 
      <li>Notification is not closeable via close btn, overlay or esc key</li>
  <button type="button">Confirm</button>

4. Create an ajax modal which loads data from an external url.

<button type="button" data-modal-target="#modal-3">Lanuch</button>
<div id="modal-3" class="modal-3 flex-modal-hide">
  onCreate: function( api ) {
    var $modalContent = $(this).children();

      url: 'ajax.html',
      cache: false,
      success: function( data ) {

5. You can add custom animations to the modals in pure CSS and/or JavaScript if you want.

.modal-3 { transition: opacity .4s; }

.modal-3 .flex-modal-item__content {
  transition: transform .4s;
  transform: translateY(100px);

.modal-3.flex-modal-item--visible .flex-modal-item__content { transform: translateY(0); }

6. Possible plugin options with default options. The options as shown below also can be passed in via data attributes as you seen in example 2.

// custom markup for close button
closeBtnMarkup: '<button class="flex-modal-item__close" type="button">x</button>',

// ayuto close other opened modals
autoCloseOthers: true,

// close the modal by click on the background overlay
closeOnOverlayClick: true,

// close the modal by press on ESC key
closeOnEscKey: true,

// callbacks
onCreate: function() {},
onOpen: function() {},
onClose: function() {}

7. The API methods to close & open modal windows manually.

// close a specified modal window

// open a specified modal window

Change log:


  • animations fixed
  • 2 more events added: afterClose and -Open

About Author:

Author: Florian Capelle

Website: https://github.com/floriancapelle/jquery-flex-modal

This awesome jQuery plugin is developed by floriancapelle. For more Advanced Usages, please check the demo page or visit the official website.