Modal

Use Bootstrap’s JavaScript modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content.

Modal components

 <!--modal compoments-->
<div class="modal" tabindex="-1">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">Modal title</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <p>Modal body text goes here.</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>
<!-- Live demo -->
<!--button trigger modal-->
<button type="button" class="btn btn-primary" data-bs-toggle="modal"
  data-bs-target="#exampleModal">
  Launch demo modal
</button>

<!--modal-->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel"
  aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h1 class="modal-title fs-5" id="exampleModalLabel">Modal title</h1>
        <button type="button" class="btn-close" data-bs-dismiss="modal"
          aria-label="Close"></button>
      </div>
      <div class="modal-body">
        Woo-hoo, you're reading this text in a modal!
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

Static backdrop

 <!--Static backdrop-->
<!--button trigger modal-->
<button type="button" class="btn btn-primary" data-bs-toggle="modal"
  data-bs-target="#staticBackdrop">
  Launch static backdrop modal
</button>

<!--modal-->
<div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false"
  tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h1 class="modal-title fs-5" id="staticBackdropLabel">Modal title</h1>
        <button type="button" class="btn-close" data-bs-dismiss="modal"
          aria-label="Close"></button>
      </div>
      <div class="modal-body">
        I will not close if you click outside of me. Don't even try to press escape key.
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Understood</button>
      </div>
    </div>
  </div>
</div>

Scrolling long content

<!--scrollable modal-->
  <button type="button" class="btn btn-primary" data-bs-toggle="modal"
    data-bs-target="#exampleModalLong">
    Launch demo modal
  </button>
  <!--modal-->
  <div class="modal fade" id="exampleModalLong" tabindex="-1"
    aria-labelledby="exampleModalLongLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <h1 class="modal-title fs-5" id="exampleModalLongLabel">Modal title</h1>
          <button type="button" class="btn-close" data-bs-dismiss="modal"
            aria-label="Close"></button>
        </div>
        <div class="modal-body" style="min-height: 1500px;">
          <p>This is some placeholder content to show the scrolling behavior for modals. Instead of
            repeating the text in the modal, we use an inline style to set a minimum height, thereby
            extending the length of the overall modal and demonstrating the overflow scrolling. When
            content becomes longer than the height of the viewport, scrolling will move the modal as
            needed.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
          <button type="button" class="btn btn-primary">Save changes</button>
        </div>
      </div>
    </div>
  </div>

You can also create a scrollable modal that allows scroll the modal body by adding .modal-dialog-scrollable to .modal-dialog .

Scrolling long content

<!--Scrollable modal-->
  <button type="button" class="btn btn-primary" data-bs-toggle="modal"
    data-bs-target="#exampleModalLong">
    Launch demo modal
  </button>
  <!--modal-->
  <div class="modal fade" id="exampleModalLong" tabindex="-1"
    aria-labelledby="exampleModalLongLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <h1 class="modal-title fs-5" id="exampleModalLongLabel">Modal title</h1>
          <button type="button" class="btn-close" data-bs-dismiss="modal"
            aria-label="Close"></button>
        </div>
        <div class="modal-body" style="min-height: 1500px;">
          <p>This is some placeholder content to show the scrolling behavior for modals. Instead of
            repeating the text in the modal, we use an inline style to set a minimum height, thereby
            extending the length of the overall modal and demonstrating the overflow scrolling. When
            content becomes longer than the height of the viewport, scrolling will move the modal as
            needed.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
          <button type="button" class="btn btn-primary">Save changes</button>
        </div>
      </div>
    </div>
  </div>

Vertically centered

<!--button trigger modal-->
<button type="button" class="btn btn-primary mb-2 mb-lg-0" data-bs-toggle="modal"
  data-bs-target="#exampleModalCenter">
  Vertically centered modal
</button>

<!--Modal-->
<div class="modal fade" id="exampleModalCenter" tabindex="-1" aria-labelledby="exampleModalLabel"
  aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered">
    <div class="modal-content">
      <div class="modal-header">
        <h1 class="modal-title fs-5" id="exampleModalCenter">Modal title</h1>
        <button type="button" class="btn-close" data-bs-dismiss="modal"
          aria-label="Close"></button>
      </div>
      <div class="modal-body">
        This is a vertically centered modal.
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>
<!--button trigger modal-->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModalCenteredScrollable">
  Vertically centered scrollable modal
</button>
<!--Modal-->
<div class="modal fade" id="exampleModalCenteredScrollable" tabindex="-1"
  aria-labelledby="exampleModalCenteredScrollable" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
    <div class="modal-content">
      <div class="modal-header">
        <h1 class="modal-title fs-5" id="exampleModalCenteredScrollableTitle">Modal title</h1>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <p>This is some placeholder content to show a vertically centered modal. We've added some extra copy here to show how vertically centering the modal works when combined with scrollable modals. We also use some repeated line breaks to quickly extend the height of the content, thereby triggering the scrolling. When content becomes longer than the predefined max-height of modal, content will be cropped and scrollable within the modal.</p>
        <br><br><br><br><br><br><br><br><br><br>
        <p>Just like that.</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

Tooltips and popovers

<!--Button trigger modal-->
<button type="button" class="btn btn-primary" data-bs-toggle="modal"
  data-bs-target="#exampleModalPopovers">
  Launch demo modal
</button>
<!--modal-->
<div class="modal fade" id="exampleModalPopovers" tabindex="-1"
  aria-labelledby="exampleModalPopovers" aria-hidden="true">
  <div class="modal-dialog ">
    <div class="modal-content">
      <div class="modal-header">
        <h1 class="modal-title fs-5" id="exampleModalPopovers">Modal title</h1>
        <button type="button" class="btn-close" data-bs-dismiss="modal"
          aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <h2 class="fs-5">Popover in a modal</h2>
        <p>This <button class="btn btn-secondary" data-bs-toggle="popover"
            data-bs-content="Popover body content is set in this attribute."
            data-bs-container="#exampleModalPopovers"
            data-bs-original-title="Popover title">button</button>
          triggers a popover on click.</p>
        <hr>
        <h2 class="fs-5">Tooltips in a modal</h2>
        <p><a href="#" data-bs-toggle="tooltip" data-bs-container="#exampleModalPopovers"
            data-bs-original-title="Tooltip">This link</a> and <a href="#"
            data-bs-toggle="tooltip" data-bs-container="#exampleModalPopovers"
            data-bs-original-title="Tooltip">that link</a> have tooltips on hover.</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>

</div>

Using the grid

<!--using grid-->
  <button type="button" class="btn btn-primary" data-bs-toggle="modal"
    data-bs-target="#gridSystemModal">
    Launch demo modal
  </button>
  <!--modal-->
  <div class="modal fade" id="gridSystemModal" tabindex="-1" aria-labelledby="gridSystemModal"
    aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <h1 class="modal-title fs-5" id="gridSystemModal">Modal title</h1>
          <button type="button" class="btn-close" data-bs-dismiss="modal"
            aria-label="Close"></button>
        </div>
        <div class="modal-body">
          <div class="modal-body">
            <div class="container-fluid">
              <div class="row">
                <div class="col-md-4"> .col-md-4</div>
                <div class="col-md-4 ms-auto">.col-md-4 .ms-auto</div>
              </div>
              <div class="row">
                <div class="col-md-3 ms-auto">.col-md-3 .ms-auto</div>
                <div class="col-md-2 ms-auto">.col-md-2 .ms-auto</div>
              </div>
              <div class="row">
                <div class="col-md-6 ms-auto">.col-md-6 .ms-auto</div>
              </div>
              <div class="row">
                <div class="col-sm-9">
                  Level 1: .col-sm-9
                  <div class="row">
                    <div class="col-8 col-sm-6">
                  Level 2: .col-8 .col-sm-6
                    </div>
                    <div class="col-4 col-sm-6">
                  Level 2: .col-4 .col-sm-6
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
          <button type="button" class="btn btn-primary">Save changes</button>
        </div>
      </div>
    </div>
  </div>

Varying modal content


<!--Varying modal content-->
<div class="modal fade" id="exampleModal1" tabindex="-1" aria-labelledby="exampleModalLabel1" aria-hidden="true">
<div class="modal-dialog">
  <div class="modal-content">
    <div class="modal-header">
      <h1 class="modal-title fs-5" id="exampleModalLabel1">New message</h1>
      <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
    </div>
    <div class="modal-body">
      <form>
        <div class="mb-3">
          <label for="recipient-name" class="col-form-label">Recipient:</label>
          <input type="text" class="form-control" id="recipient-name">
        </div>
        <div class="mb-3">
          <label for="message-text" class="col-form-label">Message:</label>
          <textarea class="form-control" id="message-text"></textarea>
        </div>
      </form>
    </div>
    <div class="modal-footer">
      <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
      <button type="button" class="btn btn-primary">Send message</button>
    </div>
  </div>
</div>
</div>

Toggle between modals

 <!--toggle between modals-->
<div class="modal fade" id="exampleModalToggle" aria-hidden="true" aria-labelledby="exampleModalToggleLabel" tabindex="-1">
  <div class="modal-dialog modal-dialog-centered">
      <div class="modal-content">
        <div class="modal-header">
          <h1 class="modal-title fs-5" id="exampleModalToggleLabel">Modal 1</h1>
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <div class="modal-body">
          Show a second modal and hide this one with the button below.
        </div>
        <div class="modal-footer">
          <button class="btn btn-primary" data-bs-target="#exampleModalToggle2" data-bs-toggle="modal">Open second modal</button>
        </div>
      </div>
    </div>
  </div>
  <div class="modal fade" id="exampleModalToggle2" aria-hidden="true" aria-labelledby="exampleModalToggleLabel2" tabindex="-1">
    <div class="modal-dialog modal-dialog-centered">
      <div class="modal-content">
        <div class="modal-header">
          <h1 class="modal-title fs-5" id="exampleModalToggleLabel2">Modal 2</h1>
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <div class="modal-body">
          Hide this modal and show the first with the button below.
        </div>
        <div class="modal-footer">
          <button class="btn btn-primary" data-bs-target="#exampleModalToggle" data-bs-toggle="modal">Back to first</button>
        </div>
      </div>
    </div>
  </div>
  <button class="btn btn-primary" data-bs-target="#exampleModalToggle" data-bs-toggle="modal">Open first modal</button>