Top Related Projects
No longer actively maintained.
Light and responsive lightbox script with focus on performance.
A light-weight, customizable lightbox plugin for jQuery
Featherlight is a very lightweight jQuery lightbox plugin. It's simple yet flexible and easy to use. Featherlight has minimal css and uses no inline styles, everything is name-spaced, it's completely customizable via config object and offers image, ajax and iframe support out of the box. Featherlights small footprint weights about 4kB β in total.
jQuery lightbox script for displaying images, videos and more. Touch enabled, responsive and fully customizable.
β¨ A beautiful, responsive, highly customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes. Zero dependencies. πΊπ¦
Quick Overview
Modaal is a lightweight and accessible modal window plugin for jQuery. It aims to provide a flexible and customizable solution for creating modal dialogs with a focus on accessibility and user experience.
Pros
- Highly accessible, following WCAG 2.0 Level AA standards
- Responsive and mobile-friendly design
- Customizable appearance and behavior
- Supports various content types (inline, images, video, iframes)
Cons
- Requires jQuery as a dependency
- Limited built-in animation options
- May require additional styling for complex layouts
- Not actively maintained (last update was in 2019)
Code Examples
Creating a basic modal:
$('.modal-trigger').modaal();
Opening a modal with custom options:
$('.custom-modal').modaal({
type: 'inline',
width: 700,
height: 500,
overlay_opacity: 0.8,
background: '#f4f4f4'
});
Creating an image gallery modal:
$('.gallery').modaal({
type: 'image',
width: 800,
height: 'auto',
accessible_title: 'Image Gallery'
});
Getting Started
- Include jQuery and Modaal files in your HTML:
<link rel="stylesheet" href="path/to/modaal.min.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="path/to/modaal.min.js"></script>
- Initialize Modaal on your desired elements:
$(document).ready(function() {
$('.modal-trigger').modaal();
});
- Add the necessary HTML markup:
<a href="#inline-content" class="modal-trigger">Open Modal</a>
<div id="inline-content" style="display:none;">
<h2>Modal Content</h2>
<p>This is the content of your modal.</p>
</div>
Competitor Comparisons
No longer actively maintained.
Pros of Remodal
- Lightweight and minimalistic, with a smaller file size
- Supports multiple instances on a single page
- Easier to customize with CSS variables
Cons of Remodal
- Less accessible out of the box compared to Modaal
- Fewer built-in features and options
- Less active development and community support
Code Comparison
Remodal:
$('[data-remodal-id=modal]').remodal();
Modaal:
$('.modal').modaal({
type: 'inline',
accessible_title: 'Modal Window'
});
Remodal uses a data attribute to initialize the modal, while Modaal uses a class selector and offers more configuration options in the initialization.
Both libraries provide simple ways to create modal windows, but Modaal offers more built-in features and accessibility options out of the box. Remodal is lighter and more minimalistic, which may be preferable for simpler projects or when custom styling is required. Modaal has better documentation and more active development, making it potentially easier to use and maintain in larger projects.
Light and responsive lightbox script with focus on performance.
Pros of Magnific-Popup
- Lightweight and fast, with a smaller file size
- More customization options and flexibility
- Better support for responsive design and mobile devices
Cons of Magnific-Popup
- Less accessible out of the box, requiring more manual configuration
- Not as actively maintained, with fewer recent updates
- Steeper learning curve for advanced features
Code Comparison
Magnific-Popup initialization:
$('.image-link').magnificPopup({
type: 'image',
gallery: {
enabled: true
}
});
Modaal initialization:
$('.image-link').modaal({
type: 'image',
gallery_active_class: 'gallery_active'
});
Both libraries offer similar basic functionality for creating modal popups, but Magnific-Popup provides more granular control over gallery features. Modaal, on the other hand, focuses on simplicity and accessibility, with fewer configuration options required for basic use cases.
Magnific-Popup is better suited for projects requiring extensive customization and performance optimization, while Modaal excels in creating accessible, user-friendly modals with minimal setup. The choice between the two depends on the specific needs of your project, balancing factors such as customization, accessibility, and ease of use.
A light-weight, customizable lightbox plugin for jQuery
Pros of Colorbox
- Lightweight and simple to use
- Extensive browser compatibility, including older versions
- Well-established with a large user base and community support
Cons of Colorbox
- Less modern design and fewer built-in features
- Not as accessible out-of-the-box
- Requires jQuery dependency
Code Comparison
Colorbox initialization:
$(document).ready(function(){
$(".gallery").colorbox({rel:'gallery'});
});
Modaal initialization:
$('.gallery').modaal({
type: 'image'
});
Summary
Colorbox is a lightweight and widely-used lightbox solution with broad browser support, making it suitable for projects that need to cater to older browsers. However, it lacks some modern features and accessibility options that Modaal provides out-of-the-box.
Modaal offers a more contemporary design and better accessibility features, but may have a steeper learning curve for developers accustomed to simpler lightbox solutions. Both libraries require jQuery, but Modaal's code structure is more modular and customizable.
The choice between the two depends on project requirements, target audience, and desired features. Colorbox might be preferable for simpler implementations, while Modaal could be better suited for projects prioritizing modern design and accessibility.
Featherlight is a very lightweight jQuery lightbox plugin. It's simple yet flexible and easy to use. Featherlight has minimal css and uses no inline styles, everything is name-spaced, it's completely customizable via config object and offers image, ajax and iframe support out of the box. Featherlights small footprint weights about 4kB β in total.
Pros of Featherlight
- Lightweight: Only 4kb minified and gzipped
- No dependencies: Works without jQuery or other libraries
- Flexible: Supports images, ajax, iframes, and inline content
Cons of Featherlight
- Less feature-rich: Fewer built-in options compared to Modaal
- Limited styling: Less customization options out-of-the-box
- Maintenance: Last updated in 2019, potentially less active development
Code Comparison
Featherlight:
$.featherlight('#myContent');
Modaal:
$('.inline').modaal({
content_source: '#inline-content'
});
Both libraries offer simple implementation, but Modaal provides more options for customization within the initialization. Featherlight's approach is more minimalistic, aligning with its lightweight nature.
Featherlight focuses on simplicity and performance, making it ideal for projects requiring a basic lightbox with minimal overhead. Modaal, while larger, offers more features and styling options out-of-the-box, suitable for projects needing a more comprehensive modal solution.
jQuery lightbox script for displaying images, videos and more. Touch enabled, responsive and fully customizable.
Pros of Fancybox
- More feature-rich with advanced gallery options and touch support
- Actively maintained with frequent updates and bug fixes
- Extensive documentation and examples available
Cons of Fancybox
- Paid license required for commercial use
- Larger file size due to additional features
- Steeper learning curve for advanced customizations
Code Comparison
Fancybox initialization:
Fancybox.bind("[data-fancybox]", {
// options
});
Modaal initialization:
$('.gallery').modaal({
type: 'image'
});
Both libraries offer simple initialization, but Fancybox provides more options for customization out of the box.
Key Differences
- Fancybox focuses on image galleries and media display, while Modaal is a more general-purpose modal plugin
- Modaal emphasizes accessibility features, which are less prominent in Fancybox
- Fancybox has a larger community and more third-party integrations
Use Cases
- Choose Fancybox for advanced image galleries and media presentations
- Opt for Modaal when accessibility is a top priority or for simpler modal implementations
Both libraries are capable of creating modal windows and lightboxes, but they cater to slightly different needs and preferences in terms of features, customization, and licensing.
β¨ A beautiful, responsive, highly customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes. Zero dependencies. πΊπ¦
Pros of SweetAlert2
- More actively maintained with frequent updates and bug fixes
- Larger community and ecosystem, with more third-party integrations
- Supports TypeScript out of the box
Cons of SweetAlert2
- Larger file size, which may impact page load times
- More complex API, potentially steeper learning curve for beginners
Code Comparison
Modaal:
$('.modal-trigger').modaal({
type: 'inline',
content_source: '#modal-content'
});
SweetAlert2:
Swal.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes, delete it!'
});
Both libraries offer ways to create modal dialogs, but SweetAlert2 provides more built-in options and customization out of the box. Modaal focuses on simplicity and accessibility, while SweetAlert2 offers a wider range of features and styling options.
SweetAlert2 is generally more suitable for complex applications requiring various types of alerts and confirmations, whereas Modaal might be preferred for simpler use cases or projects with a strong focus on accessibility.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
- Version 0.4.4
- Requires jQuery 1.11.2 or higher (v2 not tested, v3 works but not extensively stress tested).
- Built by Humaan
Modaal
Modaal is a WCAG 2.0 Level AA accessible modal window plugin.
Demos
Another modal plugin? why?
It's hard to find a plugin with the right mix of quality, flexibility and accessibility. We thought it would be interesting to develop something that would work in a variety of projects, furthering the cause for an accessible web.
1. Getting Setup
1.1. Installation
- Download ZIP
- First, copy and paste
js/modaal.min.js
in your project, and link to it before the closing</body>
element. - Next, you'll need to copy and paste the plugin's css into your project. We include both a SASS file and CSS file for flexibility.
- Lastly, link to your new
modaal.css
file before the closing</head>
element.
Note: This plugin requires your website or application already runs a copy of jQuery, version 1.11.2 or higher. Currently version 2 has not been tested. Version 3 works but has not been stress tested for bugs/issues.
1.2. Installation with Package Managers
Modaal is now setup and ready to be used with Bower and NPM and can be installed using the following commands.
bower install modaal
npm install modaal
1.3 Installation with CDN
Modaal is now setup and ready to be used with CDN JSDelivr
1.4. The Basics
Out of the box Modaal is setup to work using inline content using as little customisation as possible. The first thing you'll require is a link to trigger the modal window. It's recommended that your href
attribute targets a unique ID for a hidden element on the page containing your modal content. Like so:
<a href="#inline" class="inline">Show</a>
<div id="inline" style="display:none;">
<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</p>
</div>
$('.inline').modaal();
If you would prefer your trigger element is not an <a href="#">
, you can define a content_source
value like so:
<button class="inline">Show</button>
<div id="inline" style="display:none;">
<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</p>
</div>
$('.inline').modaal({
content_source: '#inline'
});
2. Configuration
2.1. Practical Example
$('.my-link').modaal({
type: 'ajax',
loading_content: 'Loading content, please wait.'
});
2.2. Configuration Options
key | type | default | values | notes |
---|---|---|---|---|
type | string | inline | ajax inline image iframe confirm video instagram | |
content_source | string | null | Accepts a string value for your target element, such as '#my-content'. This allows for when trigger element is an <a href="#"> link. Not to be confused with the already existing source event. | |
animation | string | fade | fade , none | |
animation_speed | integer | 300 | Animation speed is the duration it takes to reveal the Modaal window once triggered. It's important to note, that if you change this, you must also change the after_callback_delay below so that callback events sync up. This will be overwritten and set to 0 if type is none . | |
after_callback_delay | integer | 350 | Specify a delay value for the after open callbacks. This is necessary because with the bundled animations have a set duration in the bundled CSS. Specify a delay of the same amount as the animation duration in so more accurately fire the after open/close callbacks. Defaults 350, does not apply if animation is 'none', after open callbacks are dispatched immediately | |
is_locked | boolean | false | true false | Set this to true to disable closing the modal via keypress or by clicking the close or background. Beware that if type is confirm there will be no interface to dismiss the modal. If is_locked is true , you'd have to programmatically arrange to dismiss the modal. Confirm modals are always locked regardless of this option. |
hide_close | boolean | false | true false | Set this to true to hide the close modal button. Key press and overlay click will still close the modal. This method is best used when you want to put a custom close button inside the modal container space. |
background | string | #000 | Sets the background overlay color | |
overlay_opacity | float | 0.8 | Sets the background overlay transparency | |
overlay_close | boolean | true | true false | Controls whether the overlay background can be clicked to close. |
accessible_title | string | Dialog Window | Set the aria-label attribute value used for Accessibility purposes. | |
start_open | boolean | false | true false | Set this to true if you want the Modaal window to launch immediately on load. |
fullscreen | boolean | false | true false | Set this to true to make the Modaal fill the entire screen, false will default to own width/height attributes. |
custom_class | string | '' | Fill in this string with a custom class that will be applied to the outer most modal wrapper. | |
background_scroll | boolean | false | true false | Set this to true to enable the page to scroll behind the open modal |
should_open | boolean function | true | Set to false or make the closure return false to prevent the modal from opening | |
close_text | string | Close | String for close button text. Available for localisation and alternative languages to be used. | |
close_aria_label | string | Close (Press escape to close) | String for close button aria-label attribute (value that screen readers will read out). Available for localisation and alternative languages to be used. | |
width | integer | null | Set the desired width of the modal. | |
height | integer | null | Set the desired height of the modal. | |
gallery_active_class | string | gallery_active_item | Active class applied to the currently active image or image slide in a gallery | |
outer_controls | boolean | false | true false | Set to true to put the next/prev controls outside the Modaal wrapper, at the edges of the browser window. |
confirm_button_text | string | Confirm | Text on the confirm button. | |
confirm_cancel_button_text | string | Cancel | Text on the confirm modal cancel button. | |
confirm_title | string | Confirm Title | Title for confirm modal. Default | |
confirm_content | string | <p>This is the default confirm dialog content. Replace me through the options</p> | HTML content for confirm message | |
loading_content | string | Loading … | HTML content for loading message. | |
loading_class | string | is_loading | Class name to be applied while content is loaded via AJAX. | |
ajax_error_class | string | modaal-error | Class name to be applied when content has failed to load. Default is '' | |
instagram_id | string | null | Unique photo ID for an Instagram photo. |
2.3. Inline Attribute Configuration
Modaal has been developed to support common jQuery configuration options, but in an effort to extend functionality and widen its usage we've developed support for inline data-option-name
attribute support.
To enable this, the Modaal trigger link must have a class of modaal
, then you can add attributes to the link as needed like so:
<a href="#inline" data-modaal-type="inline" data-modaal-animation="fade" class="modaal">Show</a>
Or for non <a href="#">
elements:
<button data-modaal-content-source="#inline" data-modaal-type="inline" data-modaal-animation="fade" class="modaal">Show</button>
It's important to note, that configuration options that contain an underscore (_
) in them need to be replaced with a hyphen (-
) in it's respective html attribute. For example, overlay_opacity
configuration would read data-overlay-opacity="0.8"
.
2.4. Configuration Events
event | params | notes |
---|---|---|
before_open | event | Executed before the modaal has revealed |
after_open | modal_wrapper | Executed once the duration for Option after_callback_delay has expired after the open method is called. |
before_close | modal_wrapper | Executed once the Modaal has been instructed to close. |
after_close | Executed once the the duration for after_callback_delay has expired after the close method is called. | |
before_image_change | current_item incoming_item | Executed before the image changes in a gallery Modaal. |
after_image_change | current_item | Executed after the image has changed in a gallery Modaal. |
confirm_callback | lastFocus | Executed when the confirm button is pressed as opposed to cancel. |
confirm_cancel_callback | lastFocus | Executed when the cancel button is pressed as opposed to confirm. |
source | Callback function executed on the default source, it is intended to transform the source (href in an AJAX modal or iframe). The function passes in the triggering element as well as the default source depending of the modal type. The default output of the function is an untransformed default source. | |
ajax_success | target | Callback for when AJAX content is loaded in |
2.4.1 Working With Events
There are two approaches to using events. The first is to call the entire function() { }
in where the event configuration is set as seen below in before_open
, and the second is to reference only the JS function name where the rest of the action occurs, as seen below in after_open
.
$('.my-link').modaal({
before_open: function() {
alert('Before open');
},
after_open: myFunction
});
function myFunction() {
alert('After open');
}
3. Methods
3.1. Programatically Creating Modaals
To initialise a programatically created Modaal, but not open, it can been called like any other doc ready instance, with
$('.my-link').modaal();
Or with any options as available:
$('.my-link').modaal({
type: 'ajax',
loading_content: 'Loading content, please wait.'
});
3.2. Programatically Open a Modaal
For any modaal instance that has already been initialised, it can be triggered to open with
$('.my-link').modaal('open');
If the modaal has been programatically created and needs to open straight away, the following approach can be used to initialise and open immediately:
$('.my-link').modaal({ start_open: true });
This approach allows you to define other options that may be required as well as open immediately once it's ready.
3.3. Programatically Close a Modaal
Currently Modaal only supports a close method which can be called like so.
$('.my-link').modaal('close');
Based on this example, we know we've already established (and opened) the modal associated to the .my-link
class, so to close we use the same selector with a string of close
instead of options;
4. Tips & Tricks
4.1. Avoiding Conflicts
Through development, we've worked hard to ensure no conflicts will occur with any existing code, however it's important to note some of the classes currently in use and best to avoid in your own stylesheet. These include:
modaal-inline
, modaal-ajax
, modaal-image
, modaal-confirm
, modaal-iframe
, modaal-video
, modaal-wrapper
, modaal-outer-wrapper
, modaal-inner-wrapper
, modaal-container
, modaal-close
, modaal-content
4.2. Customising the CSS
We wanted to provide users the chance to really extend on Modaal's base through customising the modal styles to meet their own project. We understand working with various projects and differing styles how important it is to tailor the aesthetics right down to even the most minute detail.
Provided in the distribution files are both un-minified css and SASS files to best integrate with your workflow. Within the SASS file you'll find a number of variables located at the top of the document for which you can tweak as desired.
It's our recommendation, should you wish to change any styling, that you minify your final output so as to save on overall page weight. The primary recommendation would be to run the gulp dist
task which will minify the CSS (and JS if changes have been made), with another alternative to be found at cssminifier.com.
4.3. Video file URLs
The Modaal video type has been tested thoroughly using both Vimeo and Youtube. For best outcome, please ensure the url format looks like the one of the following below. We transplant this URL into an iframe which then each service provider controls all the necessary play back from there.
4.3.1. Youtube
https://www.youtube.com/embed/cBJyo0tgLnw
where the ID at the end is your unique video id. This can be found by selecting 'Share' on a youtube video, then clicking on 'Embed'. You'll find this URL within the content presented.
4.3.1. Vimeo
https://player.vimeo.com/video/109626219
where the ID at the end is your unique video id. This can be found by selecting 'Share' on a vimeo video (commonly seen on the right hand side), and by selecting the content within 'Embed'. You'll find the URL necessary towards the very beginning of that embed code inside src=""
.
5. Reporting issues and contributing code
5.1. Reporting an issue
- Please ensure the issue you're reporting is reproducible in a standalone environment, and not a result of something in your own build.
- Use jsFiddle or jsBin to provide a test page showing issue.
- In your issue, please indicate which browser, operating system and os version you're using.
- Please also indicate plugin version.
- If you have made any alterations to the plugin files (JS or CSS), please also list and include code samples.
The more information you can provide regarding an issue, the better.
5.2. Contributing to the plugin
Thanks for your contribution! Please refer to the guidelines below.
- Please ensure the issue you're reporting is reproducible in a standalone environment, and not a result of something in your own build.
- Please ensure your pull request has a base branch of
develop
selected. pull request's with basemaster
will not be accepted. - Please ensure the problem you're resolving has an open issue ticket.
- Adhere to the current style and formatting of the plugin files, including CSS, SASS and JS.
- Please ensure any changes are tested thoroughly in multiple browsers. We will do this, but if we locate bugs in the new code, the pull request will not be accepted.
- Outline all changes in your commit message and also reference the issue ticket. For example "Contribution: Fix for issue #17 - Update to XYZ file to do make it do ABC"
5.3. Development Setup
- Ensure you're running NodeJS
- Install Gulp by running
npm install --global gulp
. More details are available through the Gulp documentation. - Install the NPM dependencies by running
npm install
. (if this throws an error, trysudo
the command). - The build can now be called by running
gulp watch
to watch for SASS updates. - When you're happy with the final output, please also run
gulp dist
to minify and compress changes.
License
Copyright ΓΒ© Humaan Licensed under the MIT license.
Top Related Projects
No longer actively maintained.
Light and responsive lightbox script with focus on performance.
A light-weight, customizable lightbox plugin for jQuery
Featherlight is a very lightweight jQuery lightbox plugin. It's simple yet flexible and easy to use. Featherlight has minimal css and uses no inline styles, everything is name-spaced, it's completely customizable via config object and offers image, ajax and iframe support out of the box. Featherlights small footprint weights about 4kB β in total.
jQuery lightbox script for displaying images, videos and more. Touch enabled, responsive and fully customizable.
β¨ A beautiful, responsive, highly customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes. Zero dependencies. πΊπ¦
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot