Modals

LV Foundation provides CSS for modal components. These modals are responsive by default and capable of displaying a wide-variety of content types. They have also been pre-configured to scroll as their contents grow vertically.

Launch an example modal by clicking the button below.

Implementation

Setup

To use a modal, three components will need to be available in the DOM:

  1. A .modal-overlay, used to obscure content currently visible.
  2. A .modal-container, used to house the modal and corresponding close-button.
  3. A .page-container, used to house all non-modal related content in the DOM.

These components are demonstrated by the example HTML below.

<!-- Main page content -->
<div class="page-container">
    <!-- All other non-fixed content goes here -->
</div>

<!-- Modal Overlay -->
<div class="modal-overlay"></div>

<!-- Modal Container -->
<div class="modal-container">
    <div class="modal">
        <!-- Contents of modal go here -->
    </div>
    <button class="modal-close">
        <span class="icon icon-close"></span>
    </button>
</div>

PLEASE NOTE: The .modal-close button must come AFTER the .modal element.

Showing / Hiding

To show the modal, you need only add the .modal-active class to the <body> of the DOM. This implementation was chosen so as to prevent a user from scrolling while the modal is active.

To hide the modal, simply remove this class.

Sizing

By default, the modal displays with the small width.

There are, however, three variant sizing that will provide a modal with a max-width. You may trigger a demonstration of each below.

To use each of these modals, simply add the .small, .medium, .large, full, or full-no-gutter classes (respectively) to .modal.

Responsive Sizing

By default, these modals will also scroll as their content grows. The button below demonstrates a tall modal requiring scrolling.