To the modal on page load two things are required:
.vi-modal-body-backdrop to the body of the documentTo use the black version of the body backdrop, add .vi-modal-body-backdrop--black to the body too. (example)
As modal javascript is part of Bootstrap, to show a modal on page load use:
Where "#sg-d1ab57" is the id of the modal.
<script>
$(function() {
// Issue in order stack.
// 1. this code executed.
// 2. deferred script loaded
// 3. $.ready executed
//
// The timeout here is to ensure all library code is initialized
//
// For now the way to use is:
setTimeout(function() {
$("#sg-d1ab57").modal('show')
}, 1)
})
</script>
<!-- Modal -->
<div class="modal fade vi-modal" id="sg-d1ab57" role="dialog" tabindex="-1">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-body">
<!-- Modal Layout -->
<div class="vi-modal-layout">
<div class="vi-modal-layout__body">
<div class="vi-modal-layout__section vi-modal-layout__section--header-close">
<div class="vi-modal-layout__header vi-typesystem vi-typesystem--collapse-last">
<h3>Page Load</h3>
</div>
<div class="vi-modal-layout__close">
<!-- Button type: close -->
<button aria-label="Message dialog - click to close or navigate to the message content" data-dismiss="modal" type="button" class="vi-btn-close vi-btn-close--accent-1 vi-btn"><span class="vi-btn-close__label vi-btn__label">Close</span></button>
</div>
</div>
<div class="vi-modal-layout__section">
...
</div>
</div>
</div>
</div>
</div>
</div>
</div>
The following stylesheets are required to display this component.
The following javascript is required to display this component.
Usage documentation can be found here.
Changelog
- 09 Oct 2025 - fix(modal): Focus next focusable element when no data-dismiss attr is present
- 09 Oct 2025 - docs(modal): Add focus button test on scrolling long content example.
Fix
- 25 Jan 2022 - Fix regression remove console.log output.
- 30 Nov 2022 - Fix regression caused by page-layout iOS overscroll prevention.
- 30 Sept 2022 - CSS class
.vi-modal-body-backdrop--black opaticy. (plus missing docs)
- Stop Video Component correctly when modal is closed.
- Original
.modal-sm and .modal-md options
Changed
- Layering (z-index) to not conflict with the Pop Navigation
- A11y Focus close button on open.
Added
- 23 Nov 2022 - Additional backdrop colors opaque and no blur.
- 22 Nov 2022 - Additional backdrop colors with PBS support.
- 14 Oct 2022 - Add
.modal-screen option for screen sized modal.
- 28 Sept 2022 - CSS class
.vi-modal-body-backdrop to add to the body of the page a page.
- Modifier
--black to have a black backdrop, as required by some regulations
- Example how to open the modal on page load.
- RTL support
- Initial draft
To the modal on page load two things are required:
.vi-modal-body-backdrop to the body of the documentTo use the black version of the body backdrop, add .vi-modal-body-backdrop--black to the body too. (example)
As modal javascript is part of Bootstrap, to show a modal on page load use:
Where "#sg-d1ab57" is the id of the modal.
<script>
$(function() {
// Issue in order stack.
// 1. this code executed.
// 2. deferred script loaded
// 3. $.ready executed
//
// The timeout here is to ensure all library code is initialized
//
// For now the way to use is:
setTimeout(function() {
$("#sg-d1ab57").modal('show')
}, 1)
})
</script>