Modals
Required files
SCSS files required: _components.modal.scss
JS files required: toggle-element.js
The markup
The box wrapping element requires an ID eg #modalExample
to be targeted, the two classes .modal
and .toggle-fade
, and the javascript module to be applied data-js-module="toggleElement"
The modal itself should be soley for toggling, and an inner element is required with the class .modal__bg
where the positioning, alignment, background colour etc is/can be applied.
Another inner element is also required with the class .modal__content
which is where the content can go.
To trigger opening the modal use the 'data-open-el' attribute and ID of the box data-open-el="modalExample"
To trigger closing the modal use the 'data-close-el' attribute and ID of the box data-close-el="modalExample"
Modal examples
The examples below illustrate how the modal could be used in various ways.
Inside the .modal__content
element, a box can be added with the class .modal__box
Various other helper classes are also added to create the examples.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum pellentesque hendrerit tempus. Morbi eget enim quis nisl commodo aliquet eget sed quam. Morbi ut condimentum nisl. Nam elementum suscipit elit, ut consequat libero interdum.
Donec ut ipsum
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ac convallis arcu. Integer at tellus velit. Etiam placerat nunc eros, vel tincidunt erat dapibus in. Curabitur ultrices sagittis elit, sed porta sem bibendum nec.
- Nunc non sapien ac erat vehicula suscipit
- Curabitur sit amet enim odio
- Fusce cursus eu enim nec venenatis
I am a modal title
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum pellentesque hendrerit tempus. Morbi eget enim quis nisl commodo aliquet eget sed quam. Morbi ut condimentum nisl. Nam elementum suscipit elit, ut consequat libero interdum.
In hac habitasse platea dictumst. Duis aliquet turpis quis arcu euismod, et luctus sapien facilisis. Sed imperdiet dui id mi varius gravida. Etiam convallis risus ac nulla consequat mattis. Nulla condimentum egestas pulvinar. Maecenas commodo leo in nunc luctus euismod. Sed id mi nec magna vehicula dictum ac eu velit.