Components
Modal
Add dialogs for lightboxes, user notifications, and custom content.
Stable
Requires JS
Basic modal
Add data-bima-toggle="modal" and data-bima-target="#{id}" to a trigger button. The modal itself uses .bima-modal with role and ARIA attributes.
Confirm cancellation
Are you sure you want to cancel policy POL-2024-0081? This action cannot be undone and your coverage will end immediately.
Note: Any unpaid claims will still be processed.
<!-- Trigger -->
<button class="bima-btn bima-btn--primary"
data-bima-toggle="modal"
data-bima-target="#my-modal">
Open modal
</button>
<!-- Modal -->
<div class="bima-modal" id="my-modal" tabindex="-1"
role="dialog"
aria-labelledby="my-modal-title"
aria-modal="true">
<div class="bima-modal__dialog">
<div class="bima-modal__content">
<div class="bima-modal__header">
<h5 class="bima-modal__title" id="my-modal-title">Modal title</h5>
<button type="button" class="bima-close"
data-bima-dismiss="modal" aria-label="Close">
<svg ...></svg>
</button>
</div>
<div class="bima-modal__body">
<p>Modal body content here.</p>
</div>
<div class="bima-modal__footer">
<button type="button" class="bima-btn bima-btn--ghost"
data-bima-dismiss="modal">Cancel</button>
<button type="button" class="bima-btn bima-btn--primary">Confirm</button>
</div>
</div>
</div>
</div>Wide modal
Add .bima-modal--lg or .bima-modal--xl (also .bima-modal--sm) directly on the modal for larger or smaller dialogs.
<div class="bima-modal bima-modal--lg" id="wide-modal" ...> ... </div>
Scrollable modal
Add .bima-modal--scrollable to let the .bima-modal__body scroll independently while the header and footer stay fixed.
<div class="bima-modal bima-modal--scrollable" ...> <div class="bima-modal__header"> … </div> <div class="bima-modal__body"> … long content … </div> <div class="bima-modal__footer"> … </div> </div>
JavaScript API
// Show modal
BIMA.modal('#my-modal', 'show');
// Hide modal
BIMA.modal('#my-modal', 'hide');
// Toggle modal
BIMA.modal('#my-modal', 'toggle');
// Listen for events
const modal = document.getElementById('my-modal');
modal.addEventListener('bima:modal:show', () => console.log('Opening'));
modal.addEventListener('bima:modal:shown', () => console.log('Fully open, focus set'));
modal.addEventListener('bima:modal:hide', () => console.log('Closing'));
modal.addEventListener('bima:modal:hidden', () => console.log('Fully closed'));