Modals
Bootstrap 5-style dialogs with focus trap, scroll lock, stacking, lifecycle events, dynamic content, density variants, color headers, and promise-based alert / confirm factories.
Basic Modal
Trigger a modal by opening it with data-lp-toggle="modal" and data-lp-target="#id". Close it with data-lp-dismiss="modal" or Esc.
Modal Sizes
Sizes: sm (380px), default (500px), lg (720px), xl (960px), and fullscreen. Apply the class on the .lp-modal root.
Modal Density
Control header / body / footer padding with a density class on the root. lp-modal-compact shrinks everything (and drops the title to text-sm); lp-modal-relaxed expands it.
Centered and Scrollable
Add lp-modal-dialog-centered or lp-modal-dialog-scrollable to .lp-modal-dialog. They combine freely.
Static Backdrop
Set data-lp-backdrop="static" to block backdrop-click dismiss (a subtle bounce signals the intent). Pair with data-lp-keyboard="false" to also block Esc.
Contextual Modal Headers
Solid header lp-modal-{color} or soft header lp-modal-{color}-light on the root. Supported colors: primary, success, danger, warning, info, dark.
Solid headers
Soft (light) headers
Alert Modals — Modal.alert()
Promise-based alert dialog with a centered icon. Resolves when dismissed.
Confirmation Dialogs — Modal.confirm()
Promise-based confirm dialog. Resolves true on OK, false on Cancel / backdrop / Esc.
Result log:
Programmatic Control & Dynamic Content
Get or create a modal instance and mutate its contents at runtime — useful for shared dialogs that change purpose between opens.
Form in a Modal
Forms inside modals focus-trap naturally. Wire submit via the footer’s primary button.
Nested / Stacked Modals
Modals stack automatically. Each additional modal gets a higher z-index (+10) and its own backdrop. Esc closes only the topmost one.
Mobile Fullscreen
Use lp-modal-fullscreen-{bp}-down to make the modal fullscreen below a breakpoint. Supported: sm (576px), md (768px), lg (992px), xl (1200px), 2xl (1400px). Resize the window below 768px and re-open.
JavaScript API
Full reference for the Modal class exposed on window.Launchpad.Modal.
Event log:
CSS / Data Reference
| Class / Attribute | Description |
|---|---|
.lp-modal | Root overlay container (fixed, full-viewport) |
.lp-modal-dialog | The visible card — background, radius, shadow, stacking for header / body / footer. (Legacy .lp-modal-content markup still works as a transparent passthrough.) |
.lp-modal-header / -title / -close | Header parts |
.lp-modal-body | Body region |
.lp-modal-footer | Footer buttons |
.lp-modal-sm / -lg / -xl / -fullscreen | Size: 380 / 500 (default) / 720 / 960 / 100vw |
.lp-modal-fullscreen-{sm|md|lg|xl|2xl}-down | Fullscreen below a breakpoint |
.lp-modal-compact / -relaxed | Density — smaller or larger paddings |
.lp-modal-dialog-centered | Vertically center (on .lp-modal-dialog) |
.lp-modal-dialog-scrollable | Scrollable body (on .lp-modal-dialog) |
.lp-modal-{color} | Solid header: primary, success, danger, warning, info, dark |
.lp-modal-{color}-light | Soft / pastel header |
data-lp-toggle="modal" | Trigger — opens the modal in data-lp-target |
data-lp-target="#id" | Selector of the modal to open |
data-lp-dismiss="modal" | Close button (inside or outside the modal) |
data-lp-backdrop="true | false | static" | Backdrop mode |
data-lp-keyboard="true | false" | Esc-key dismiss |
data-lp-focus="true | false" | Focus trap on show |
data-lp-size | sm | default | lg | xl | fullscreen |
data-lp-centered / data-lp-scrollable | Dialog-level options (additive with markup classes) |
lp:modal:show / shown / hide / hidden | Lifecycle events (bubble; show/hide are preventable) |
Basic Modal
Backdrop, focus trap and scroll lock are wired by data-lp-component="modal". Click the backdrop, press Esc, or use a dismiss button to close.
Small modal
Max width: 380px.
Default modal
Max width: 500px.
Large modal
Max width: 720px.
Extra large modal
Max width: 960px.
Fullscreen modal
Max width: 100vw.
Relaxed
Comfortable padding for long-form dialogs.
Notice the expanded header / body / footer padding.
Normal (default)
Standard padding for most use cases.
Notice the default header / body / footer padding.
Compact
Minimal padding and a smaller title — great for toolbars or quick prompts.
Notice the reduced header / body / footer padding.
Centered
Scrollable body
Paragraph 1 — body content scrolls independently while the header and footer stay fixed.
Paragraph 2 — body content scrolls independently while the header and footer stay fixed.
Paragraph 3 — body content scrolls independently while the header and footer stay fixed.
Paragraph 4 — body content scrolls independently while the header and footer stay fixed.
Paragraph 5 — body content scrolls independently while the header and footer stay fixed.
Paragraph 6 — body content scrolls independently while the header and footer stay fixed.
Paragraph 7 — body content scrolls independently while the header and footer stay fixed.
Paragraph 8 — body content scrolls independently while the header and footer stay fixed.
Paragraph 9 — body content scrolls independently while the header and footer stay fixed.
Paragraph 10 — body content scrolls independently while the header and footer stay fixed.
Paragraph 11 — body content scrolls independently while the header and footer stay fixed.
Paragraph 12 — body content scrolls independently while the header and footer stay fixed.
Paragraph 13 — body content scrolls independently while the header and footer stay fixed.
Paragraph 14 — body content scrolls independently while the header and footer stay fixed.
Paragraph 15 — body content scrolls independently while the header and footer stay fixed.
Paragraph 16 — body content scrolls independently while the header and footer stay fixed.
Paragraph 17 — body content scrolls independently while the header and footer stay fixed.
Paragraph 18 — body content scrolls independently while the header and footer stay fixed.
Paragraph 19 — body content scrolls independently while the header and footer stay fixed.
Paragraph 20 — body content scrolls independently while the header and footer stay fixed.
Paragraph 21 — body content scrolls independently while the header and footer stay fixed.
Paragraph 22 — body content scrolls independently while the header and footer stay fixed.
Paragraph 23 — body content scrolls independently while the header and footer stay fixed.
Paragraph 24 — body content scrolls independently while the header and footer stay fixed.
Paragraph 25 — body content scrolls independently while the header and footer stay fixed.
Centered + scrollable
Line 1.
Line 2.
Line 3.
Line 4.
Line 5.
Line 6.
Line 7.
Line 8.
Line 9.
Line 10.
Line 11.
Line 12.
Line 13.
Line 14.
Line 15.
Line 16.
Line 17.
Line 18.
Line 19.
Line 20.
Confirm before closing
Primary header
Solid primary header variant. Uses .lp-modal-primary on the root.
Success header
Solid success header variant. Uses .lp-modal-success on the root.
Danger header
Solid danger header variant. Uses .lp-modal-danger on the root.
Warning header
Solid warning header variant. Uses .lp-modal-warning on the root.
Info header
Solid info header variant. Uses .lp-modal-info on the root.
Dark header
Solid dark header variant. Uses .lp-modal-dark on the root.
Primary light header
Soft primary header variant. Uses .lp-modal-primary-light on the root.
Success light header
Soft success header variant. Uses .lp-modal-success-light on the root.
Danger light header
Soft danger header variant. Uses .lp-modal-danger-light on the root.
Warning light header
Soft warning header variant. Uses .lp-modal-warning-light on the root.
Info light header
Soft info header variant. Uses .lp-modal-info-light on the root.
Dynamic shell
Use the buttons on the page to mutate this modal's title, body, and footer at runtime.
New project
Parent modal
Each new modal gets its own backdrop and sits 10 z-indexes above the one underneath. Esc closes only the topmost modal.
Child modal
Fullscreen under 768px
On screens 768px or wider, this modal sits at its default 500px width. Resize the window below 768px (or open on a phone) and re-open — it covers the whole viewport.
Uses lp-modal-fullscreen-md-down.
Lifecycle demo
Open and close this modal — the log below captures every lifecycle event.