Because of the interactive features of modals, you must ensure that you are completing all required elements appropriately. For this reason, we recommend not overusing modals, as it is better for the content to live directly on the page unless an enlarged version is specifically needed.
HTML warning – remember to change IDs of the target infographics. You cannot have multiple identical IDs on one page.
Lightbox/Modal with Infographic
Use this version in its entirety when placing an infographic or large featured image within a modal. Notice that there are variations – modal-lg and modal-xl. Choose the option that best fits your content. The modal-lg class displays at a max-width of 800px, and the modal-xl class displays at a max-width of 1000px.
Two elements are needed to make a modal functional:
- An initiating button/link,
- Modal content
![alt text](/images/Screen-Shot-2019-01-23-at-2.39.58-PM-768x217.png)
A modal always has an indicator to enlarge the infographic, but it’s also possible to initiate a modal via a link. Below, you’ll see the code that is mandatory for the fullscreen button.
The fullscreen button is lightly transparent and lives on the upper right side of the infographic container. The aria-label
attribute is important here as this button has no apparent functional text to support it otherwise.
Always make sure you:
- update the ID in the
data-target
value to match the ID of the modal. If you have multiple modals on a page, their IDs must be unique.
- update the
<span class="sr-only">...</span>
text if the functionality of the button is anything besides opening the infographic in a larger container
Option B – Linked Text
![alt text](/images/Screen-Shot-2019-01-23-at-2.39.52-PM-300x67.png)
Always make sure to:
- update the ID in the
data-target
value to match the ID of the modal. If you have multiple modals on a page, their IDs must be unique
- update the
aria-label
of the link if the text is not descriptive enough to satisfy accessibility requirements
- Optional – you can remove the “enlarge” indicator item by deleting the
<i></i>
tag if you’d like to use this as a simple link.
Step 2: Create the modal container and supporting content:
Adding the modal container for the complete infographic organism
A modal must have content, and when you’re using infographics, it’s a simple process. Replace the following values below:
<img>
src values (they must match) for the on-page and in-modal versions <span class="sr-only">...</span>
if the functionality of the open button needs to be described differently
- Update the caption and caption body for both the on-page and in-modal versions
- Make sure the data-target attribute of your
<a>
link or <button>
matches the ID of the modal container. In the example below, data-attribute="#exampleModal"
matches the <div class="modal fade" id="exampleModal">
element
Lightbox/Modal with Table
For WTW, we use the lightbox/modal for infographics and tables. Below you will find the proper structure for a table within a modal. Note that there are specific classes that have been added that must remain in order for the proper styles to render.
Step 1: Add the initiating link
The first element is a link – this can be called from anywhere (as a standalone link, as an in-body link, etc). Simply update the “data-target”
value with the ID of the modal. Remember, if you are using multiple modals on the page, each ID must be unique, otherwise the modals will break. To trigger the modal, use simple text with the appropriate aria-label
, if required. Ensure that the data-target has the same value as the ID of the modal it will open.
Step 2: Add the modal and content
Next, add the modal. This is set to be hidden on the page until clicking on the modal reveals the popup. It is recommended to modify the modal code outside of Sitecore or any CMS, and simply copy and paste your HTML into the editor. Note that some of the classes are different here on the table in order to achieve the proper styling within the modal. Those classes – on the <table>
element, p-3
, d-block
and bg-white
– are mandatory within a table in a modal. Additionally, there is a bg-white
class on the <caption>
tag. If you ensure that you’ve added those classes to your table, you’re ready to go.
Optional Configurations
Large modal vs. Extra large modal
If you need your modal to display wider than 800px, use the modal-xl
class on the modal-dialog container, which will increase the width of the modal to 1000px.
Do not use a lightbox when it isn’t needed to display the content.
In the example below, the image was created to the proper specifications and the text is large enough to match the body text. In this case, a lightbox is unnecessary, clutters the image, and complicates the production of the page.
![alt text](/images/lightbox-do-not-use-when.png)
![alt text](/images/lightbox-does-not-need-1024x544.png)
Do not place the caption text above the lightbox.
Similar to Inline Images with Captions, the caption must always be placed underneath the image.