Drop-in semantic component. See examples, sizes, variants, and source.
Centered overlay dialog. Wrap a modal in a
modal-overlay, give the trigger a
data-modal="..." attribute, and add modifiers for
size (xs sm xl lg fullscreen), intent
(positive negative warning info), or layout
(scrollable). Open / close behaviour is wired by
modal.js.
Modal System
Trigger Button - A button with data-modal="modal-id" attribute
Modal HTML - The modal structure with matching id="modal-id"
JavaScript - Drop in one file: <script src="/base/components/modal.js"></script> (zero dependencies)
Basic Modal
Basic Modal
This is a basic modal with standard content.
This is the modal content area. You can place any content here.
<!-- Trigger Button -->
<button class="button" data-modal="basic-modal">Open Basic Modal</button>
<!-- Modal HTML -->
<div id="basic-modal" class="modal-overlay hidden" aria-hidden="true">
<div class="modal">
<div class="header">
<div>
<h3 class="title">Basic Modal</h3>
<p class="description">This is a basic modal with standard content.</p>
</div>
<button class="button close" type="button" aria-label="Close modal">
<svg
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
fill="currentColor"
class="size-5"
>
<path
d="M11.9997 10.5865L16.9495 5.63672L18.3637 7.05093L13.4139 12.0007L18.3637 16.9504L16.9495 18.3646L11.9997 13.4149L7.04996 18.3646L5.63574 16.9504L10.5855 12.0007L5.63574 7.05093L7.04996 5.63672L11.9997 10.5865Z"
></path>
</svg>
</button>
</div>
<div class="content">
<p>This is the modal content area. You can place any content here.</p>
</div>
<div class="footer">
<button class="button ghost">Cancel</button>
<button class="button primary">Confirm</button>
</div>
</div>
</div>
This feature will be available in the next update. Stay tuned for more improvements coming soon.
<!-- Trigger Button -->
<button class="button primary" data-modal="info-modal">Info Modal</button>
<!-- Modal HTML -->
<div id="info-modal" class="modal-overlay hidden" aria-hidden="true">
<div class="modal info">
<div class="header">
<div class="flex items-start gap-3">
<i class="icon info w-6 h-6">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
>
<circle cx="12" cy="12" r="10"></circle>
<line x1="12" y1="16" x2="12" y2="12"></line>
<line x1="12" y1="8" x2="12.01" y2="8"></line>
</svg>
</i>
<div>
<h3 class="title">Information</h3>
<p class="description">Important information for you to know.</p>
</div>
</div>
<button class="button close" type="button" aria-label="Close modal">
<svg
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
fill="currentColor"
class="size-5"
>
<path
d="M11.9997 10.5865L16.9495 5.63672L18.3637 7.05093L13.4139 12.0007L18.3637 16.9504L16.9495 18.3646L11.9997 13.4149L7.04996 18.3646L5.63574 16.9504L10.5855 12.0007L5.63574 7.05093L7.04996 5.63672L11.9997 10.5865Z"
></path>
</svg>
</button>
</div>
<div class="content">
<p>
This feature will be available in the next update. Stay tuned for more improvements coming
soon.
</p>
</div>
<div class="footer">
<button class="button primary">Got it</button>
</div>
</div>
</div>
Complete Examples
Basic Modal - Full Implementation
<!-- Trigger Button -->
<button class="button primary" data-modal="my-modal">
Open Modal
</button>
<!-- Modal HTML (place at end of body) -->
<div id="my-modal" class="modal-overlay hidden" aria-hidden="true">
<div class="modal">
<div class="header">
<div>
<h3 class="title">Confirm Action</h3>
<p class="description">Are you sure you want to proceed?</p>
</div>
<button class="button close" aria-label="Close">
<i class="icon x w-5 h-5">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="18" y1="6" x2="6" y2="18"></line>
<line x1="6" y1="6" x2="18" y2="18"></line>
</svg>
</i>
</button>
</div>
<div class="content">
<p>This action cannot be undone. All data will be permanently deleted.</p>
</div>
<div class="footer">
<button class="button ghost">Cancel</button>
<button class="button negative">Delete</button>
</div>
</div>
</div>
<!-- Trigger Button --> <button class="button primary" data-modal="my-modal"> Open Modal
</button> <!-- Modal HTML (place at end of body) --> <div id="my-modal"
class="modal-overlay hidden" aria-hidden="true"> <div class="modal"> <div
class="header"> <div> <h3 class="title">Confirm Action</h3> <p
class="description">Are you sure you want to proceed?</p> </div> <button
class="button close" aria-label="Close"> <i class="icon x w-5 h-5"> <svg
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2"> <line x1="18" y1="6" x2="6" y2="18"></line> <line x1="6" y1="6"
x2="18" y2="18"></line> </svg> </i> </button> </div> <div
class="content"> <p>This action cannot be undone. All data will be permanently
deleted.</p> </div> <div class="footer"> <button class="button
ghost">Cancel</button> <button class="button negative">Delete</button>
</div> </div> </div>
JavaScript API
Opening Modals Programmatically
// Open a modal by id
Modal.open('my-modal');
// Close a modal by id (or pass the overlay element directly)
Modal.close('my-modal');
// Close every open modal
Modal.closeAll();
// Open a modal by id Modal.open('my-modal'); // Close a modal by id (or pass the overlay element
directly) Modal.close('my-modal'); // Close every open modal Modal.closeAll();
// Create your own trigger logic
document.getElementById('custom-trigger').addEventListener('click', function() {
// Do something before opening
if (confirm('Are you ready to open the modal?')) {
Modal.open('my-modal');
}
});
// Create your own trigger logic document.getElementById('custom-trigger').addEventListener('click',
function() { // Do something before opening if (confirm('Are you ready to open the modal?')) {
Modal.open('my-modal'); } });
Class API Reference
Type
Class
Usage
Notes
Base
modal-overlay
Backdrop overlay that hosts the modal
Toggle hidden via JS
modal
The dialog box itself
Always required
data-modal
Trigger attribute — value matches modal id
Wired by modal.js
Structure
header
Top bar with title and close button
Child of modal
title / description
Header text content
Inside header
close
Close button (auto-wired by JS)
Pair with button base class
icon-container
Decorative icon slot in colored modals
Inside header
content
Body of the modal
Add scrollable for tall content
footer
Bottom action bar
Add center / between for alignment
Size
xs
Tiny — minimal content
Modifier on modal
sm
Small — quick confirmations
Modifier on modal
(default)
Medium — most use cases
No size class needed
xl
Large — detailed forms
Modifier on modal
lg
Big — full-window content
Modifier on modal
fullscreen
Covers entire viewport
Modifier on modal
Color (Intent)
(default)
Neutral / gray
No class needed
positive
Success — green accent
Modifier on modal
negative
Error / destructive — red accent
Modifier on modal
warning
Caution — yellow / orange accent
Modifier on modal
info
Information — blue accent
Modifier on modal
Layout
scrollable
Capped height with internal scroll
Use on modal and/or content
center
Center-aligns footer buttons
Modifier on footer
between
Space-between footer buttons
Modifier on footer
States
hidden
Closed overlay state
Toggle on modal-overlay
Basic Modal
This is a basic modal with standard content and actions.
This is the modal content area. You can place any content here, including forms, images, lists, or any other HTML elements.
Payment Received
Your payment has been successfully received.
Thank you for your payment. You can now access all premium features.
Warning
Please review this important information.
This action cannot be undone. Are you sure you want to proceed?
Information
Important information for you to know.
This feature will be available in the next update. Stay tuned for more improvements coming soon.
Error
Something went wrong.
An error occurred while processing your request. Please try again later or contact support if the problem persists.
Scrollable Content
This modal has scrollable content.
This modal demonstrates scrollable content. When the content exceeds the maximum height, a scrollbar appears.
Section 1
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Section 2
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Section 3
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Section 4
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Section 5
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium.
Section 6
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti.
Centered Actions
This modal has centered footer actions.
This modal demonstrates centered footer actions, which works well for single-action modals or when you want to draw attention to the primary action.
Fullscreen Modal
This modal takes up the entire viewport.
This fullscreen modal provides maximum space for complex applications or detailed content that requires the full viewport.
Main Content Area
This area can contain your main application interface, forms, or any complex content that benefits from the additional space.
Supporting Content
Additional information, help text, or secondary features can be displayed alongside the main content.