{% include '@bolt-elements-button/button.twig' with {
content: 'Open Modal',
attributes: {
type: 'button',
'data-bolt-modal-target': '.js-target-name',
}
} only %}
{% include '@bolt-components-modal/modal.twig' with {
content: 'This is a modal',
attributes: {
class: 'js-target-name'
},
} only %}
Prop Name | Description | Type | Default Value | Option(s) |
---|---|---|---|---|
attributes
|
A Drupal attributes object. Used to apply additional HTML attributes to the outer <bolt-modal> tag. |
object
| — |
|
width
|
Controls the width of the modal container. |
string
|
optimal
|
|
spacing
|
Controls the spacing around the modal container. |
string
|
medium
|
|
persistent
|
Enables the modal to be persistent. This will eliminate ways to close the modal and it is up to the author to provide a custom link to close the modal or redirect to another page within the modal content. Must be used in tandem with the |
boolean
|
false
|
|
persistent_return_url
|
The URL to be used on a return link. If a modal is persistent, a return link is required to provide the user a way out. Must be used in tandem with the |
string
| — |
|
theme
|
Controls the color theme of the modal container. |
string
|
xlight
|
|
scroll
|
Controls the scrolling area. |
string
|
container
|
|
uuid
|
Unique ID for modal, randomly generated if not provided. |
string
| — |
|
npm install @bolt/components-modal
This is the modal container's header.
This is the modal container's body.
This is the modal container's footer.
width
prop. The default is set to optimal
.
|
This is taking up the full width of the screen minus the gutters (about 2rem on left and right). |
---|---|
|
This is 10 out 12 columns wide, about 80% of the screen width. |
|
This is about 75 characters wide, close to optimal reading length. |
|
This adjusts to the width of the modal content. In most cases, the user must define a max-width in absolute value (do not use relative value such as %) on the modal content to get the desired results. Recommended for advanced usage. |
Additional Notes: this prop only applies to viewports equal to or above the small breakpoint (~600px). |
spacing
prop. The default is set to medium
.
|
This removes the spacing inside the modal container. |
---|---|
|
This sets small inset spacing on the modal container. |
|
This sets medium inset spacing on the modal container. |
|
This sets large inset spacing on the modal container. |
Additional Notes: this prop only applies to viewports equal to or above the small breakpoint (~600px). |
theme
prop. The default is set to xlight
.
|
This makes the modal container transparent. |
---|---|
|
This sets the xlight theme on the modal container. |
|
This sets the light theme on the modal container. |
|
This sets the dark theme on the modal container. |
|
This sets the xdark theme on the modal container. |
Additional Notes: this prop only applies to viewports equal to or above the small breakpoint (~600px). |
scroll
prop. The default is set to container
.
|
This makes the overall viewport area scrollable. |
---|---|
|
This makes the modal container itself scrollable. |
Additional Notes: this prop only applies to viewports equal to or above the small breakpoint (~600px). |
|
The Button component is the standard method to trigger a modal. |
---|---|
|
Image trigger can be created by wrapping the Trigger component around an Image component. Advanced usage: if the Image component has an absolute value (e.g. 640px) defined for |
Link trigger
|
Buttons are preferred for opening a modal, but you can use a link in a pinch. |
data-bolt-modal-target
data attribute to a trigger element, or by calling the Modal's show()
and hide()
methods directly via JavaScript.data-bolt-modal-target
on a trigger element to toggle a modal. The value of the data attribute must be a valid CSS selector that matches your target modal. When you click the trigger the modal will show if currently hidden or it will hide if currently shown.
data-bolt-modal-target
data attribute.show()
and hide()
methods to toggle a modal. Before calling any methods on the modal you must first wait for the Modal component to be ready. See the demo below for reference.
show()
method.hide()
method will be called when you click the button below.<script>
const modal = document.querySelector('.js-bolt-modal--js-demo');
const showButton = document.querySelector('.js-bolt-modal-trigger--open');
const hideButton = document.querySelector('.js-bolt-modal-trigger--close');
// Promise ensures Modal is defined before calling hide/show
customElements.whenDefined('bolt-modal').then(() => {
showButton.addEventListener('click', () => {
modal.show();
})
hideButton.addEventListener('click', () => {
modal.hide();
})
});
</script>
data-bolt-modal-target
attribute. The value of this attribute is the target modal's class. There is JS that will handle the opening on target modal based on the attribute's value.video-js
requires a couple of attributes to delay the initialization. There are four attributes that are required, three of these replace the default Brightcove attributes.full_bleed
prop must be set to false
.This is a paragraph. Suspendisse dictum feugiat nisl ut dapibus. Mauris iaculis porttitor posuere. Praesent id metus massa, ut blandit odio. Proin quis tortor orci. Etiam at risus et justo dignissim congue. Donec congue lacinia dui, a porttitor lectus condimentum laoreet. Nunc eu ullamcorper orci. Quisque eget odio ac lectus vestibulum faucibus eget in metus. In pellentesque faucibus vestibulum. Nulla at nulla justo, eget luctus tortor. Nulla facilisi. Duis aliquet egestas purus in blandit. Curabitur vulputate, ligula lacinia scelerisque tempor, lacus lacus ornare ante, ac egestas est urna sit amet arcu. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed molestie augue sit amet leo consequat posuere. Vestibulum ante.
width
to full
to maximize space. For example, you can build a multi-column layout with the grid, band, and card components.This Is an Eyebrow
This Is a Subheadline
This is a paragraph. Suspendisse dictum feugiat nisl ut dapibus. Mauris iaculis porttitor posuere. Praesent id metus massa, ut blandit odio. Proin quis tortor orci. Etiam at risus et justo dignissim congue. Donec congue lacinia dui, a porttitor lectus condimentum laoreet. Nunc eu ullamcorper orci. Quisque eget odio ac lectus vestibulum faucibus eget in metus. In pellentesque faucibus vestibulum. Nulla at nulla justo, eget luctus tortor. Nulla facilisi. Duis aliquet egestas purus in blandit. Curabitur vulputate, ligula lacinia scelerisque tempor, lacus lacus ornare ante, ac egestas est urna sit amet arcu. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed molestie augue sit amet leo consequat posuere. Vestibulum ante.
persistent
and persistent_return_url
. When a modal is persistent, the default close button is not shown, the only ways to close the modal is through filling out the form, hitting the return link, or hitting the escape key on the keyboard (which acts exactly like the return link).Modal content can be anything. Content authors are free to set up single or multiple column layouts. The recommended format is text content on the left and form on the right. The return link is required, which is in its own cell under both the text content and form cells. It should not be part of the free-form authorable content, instead two required fields are required for content authors to input: return link url and return link text.
(all fields are required)
<bolt-modal>
in the markup to make it render. In the following examples, we use data-bolt-modal-target
to trigger the modal. However, the same options shown on the Usage Javascript page are also available on the web component.
<button type="button" class="e-bolt-button" data-bolt-modal-target=".js-bolt-modal-demo">
Open Modal
</button>
<bolt-modal class="js-bolt-modal-demo">
This is a modal.
</bolt-modal>
header
, default
, footer
. To pass content to either the header or footer, slot
must be defined.
<button type="button" class="e-bolt-button" data-bolt-modal-target=".js-bolt-modal-basic-demo">
Open Modal
</button>
<bolt-modal class="js-bolt-modal-basic-demo">
<bolt-text slot="header">This is the header</bolt-text>
<bolt-text>This is the body (default).</bolt-text>
<bolt-text slot="footer">This is the footer</bolt-text>
</bolt-modal>
<bolt-modal>
element. Use unique combinations to customize a modal to your liking.
<button type="button" class="e-bolt-button" data-bolt-modal-target=".js-bolt-modal-advanced-demo">
Open Modal
</button>
<bolt-modal width="optimal" spacing="none" theme="none" scroll="overall" class="js-bolt-modal-advanced-demo">
<bolt-image src="/images/content/backgrounds/background-robotics-customer-service.jpg" alt="This is an image"></bolt-image>
</bolt-modal>