Quick start guide and documentation
RSL Modals are fully dynamic—content is never fixed. Every modal can be populated on demand at the moment it opens, allowing you to reuse the same modal container for countless layouts. You can open modals using simple HTML data attributes, DOM-sourced content, or pure JavaScript.
<head>)
</body>)
Modal Title
Content is written directly in HTML—ideal for simple, unchanging layouts
Hardcoded Modal
Static content lives here in the HTML
Pass title, body, and footer content through data-* attributes
Pull content from hidden elements on the page using a selector
Full programmatic control using RSL.showModal()
document.querySelector('#openBtn').addEventListener('click', () => {
RSL.showModal({
target: '#my-modal',
title: 'JavaScript Modal
',
body: 'Built entirely in code
',
footer: "",
animationIn: 'scaleIn'
});
});
Combine JavaScript control with DOM-sourced content
RSL.showModal({
target: '#my-modal',
title: 'Details
',
bodySelector: '.content-block', // pulls innerHTML from all .content-block elements
footer: "",
animationIn: 'fadeIn'
});
| Attribute | Purpose | Example |
|---|---|---|
data-modal-target |
CSS selector for modal to open | "#my-modal" |
data-animation-in |
Opening animation name | "fadeIn", "scaleIn", "rotateIn" |
data-modal-title |
HTML for modal title | "<h2>Title</h2>" |
data-modal-body |
Array of HTML strings for body | '["<p>Text</p>"]' |
data-modal-body-selector |
CSS selector to pull content from DOM | ".content-chunk" |
data-modal-footer |
HTML for modal footer | "<button>OK</button>" |
| Attribute | Purpose | Example |
|---|---|---|
data-animation-out |
Closing animation name | "fadeOut", "rotateOut" |
| Class | Purpose |
|---|---|
.modal-container |
Outer modal wrapper |
.modal |
Inner modal content box |
.modal-header |
Header section |
.modal-body |
Content section |
.modal-footer |
Footer section |
.close-modal |
Close button styling and behavior |
.default-modal-size |
Standard modal width |
.modal-buttons-right |
Right-align footer buttons |
.modal-buttons-center |
Center-align footer buttons |
| Method | Purpose |
|---|---|
RSL.openFromTrigger(element) |
Opens modal using data attributes from trigger element |
RSL.showModal(options) |
Opens modal programmatically with JavaScript options |
RSL.showModal()data-modal-body-selector to pull content from server-rendered HTML hidden on the page
data-animation-in="scaleIn" with data-animation-out="fadeOut" for variety
aria-label on close buttons for screen reader users
.modal-body for complex, responsive modal content
modal.js is loaded after layout.js and DOMPurifydata-modal-target selector matches a modal container IDrole="dialog" and aria-modal="true"data-modal-body is validdata-modal-body-selector matches existing elementsaria-modal="true" is set on the containerRSL Modals are ADA-compliant by default:
role="dialog" and aria-modal="true" for screen reader announcementsOpen modal.html for live examples
Check the cart modal example for custom styling ideas
Combine data attributes, DOM content, and JavaScript for powerful workflows