Modal

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

Modal components

Below is a static modal example (meaning its position and display have been overridden). Included are the modal header, modal body (required for padding), and modal footer (optional). We ask that you include modal headers with dismiss actions whenever possible, or provide another explicit dismiss action.

<modal :tabindex="-1">
        <model-header :dismissable="true"
            <h5 class="modal-title">Modal title</h5>
        </model-header>
        <model-body>
            <p>Modal body text goes here.</p>
        </model-body>
        <model-footer>
            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
            <button type="button" class="btn btn-primary">Save changes</button>
        </model-footer>
    </modal>

Live demo

Toggle a working modal demo by clicking the button below. It will slide down and fade in from the top of the page.

<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">
        Launch demo modal
    </button>
    <modal mainClass="fade" :tabindex="-1" id="exampleModal" ariaLabelled="exampleModalLabel" :ariaHidden="true">
        <model-header :dismissable="true"
            <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
        </model-header>
        <model-body>
            <p>Woohoo, you're reading this text in a modal!</p>
        </model-body>
        <model-footer>
            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
            <button type="button" class="btn btn-primary">Save changes</button>
        </model-footer>
    </modal>
    

Static backdrop

When backdrop is set to static, the modal will not close when clicking outside it. Click the button below to try it.

<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#staticBackdrop">
        Launch static backdrop modal
    </button>
    <modal mainClass="fade" :tabindex="-1" id="staticBackdrop" backdrop="static" ariaLabelled="staticBackdropLabel" :ariaHidden="true">
        <model-header :dismissable="true"
            <h5 class="modal-title" id="staticBackdropLabel">Modal title</h5>
        </model-header>
        <model-body>
            <p>I will not close if you click outside me. Don't even try to press escape key.</p>
        </model-body>
        <model-footer>
            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
            <button type="button" class="btn btn-primary">Understood</button>
        </model-footer>
    </modal>

Scrolling long content

When modals become too long for the user’s viewport or device, they scroll independent of the page itself. Try the demo below to see what we mean.

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

<modal mainClass="fade" :tabindex="-1" id="exampleModalScrollable" backdrop="static" ariaLabelled="exampleModalScrollableTitle" :ariaHidden="true" style="display: none;" dialogClass="modal-dialog-scrollable">
        <model-header :dismissable="true"
            <h5 class="modal-title" id="exampleModalScrollableTitle">Modal title</h5>
        </model-header>
        <model-body>
            <p>This is some placeholder content to show the scrolling behavior for modals. We use repeated line breaks to demonstrate how content can exceed minimum inner height, thereby showing inner scrolling. When content becomes longer than the prefedined max-height of modal, content will be cropped and scrollable within the modal.</p>
                <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
                <p>This content should appear at the bottom after you scroll.</p>
        </model-body>
        <model-footer>
            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
            <button type="button" class="btn btn-primary">Save changes</button>
        </model-footer>
    </modal>

Vertically centered

Add .modal-dialog-centered to .modal-dialog to vertically center the modal.

 
<modal mainClass="fade" :tabindex="-1" id="exampleModalCenter" backdrop="static" ariaLabelled="exampleModalCenterTitle" :ariaHidden="true" style="display: none;" dialogClass="modal-dialog-centered">
        <model-header :dismissable="true">
            <h5 class="modal-title" id="exampleModalCenterTitle">Modal title</h5>
        </model-header>
        <model-body>
            <p>This is a vertically centered modal.</p>
        </model-body>
        <model-footer>
            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
            <button type="button" class="btn btn-primary">Save changes</button>
        </model-footer>
    </modal>
    <modal mainClass="fade" :tabindex="-1" id="exampleModalCenteredScrollable" backdrop="static" ariaLabelled="exampleModalCenteredScrollableTitle" :ariaHidden="true" style="display: none;" dialogClass="modal-dialog-centered modal-dialog-scrollable">
        <model-header :dismissable="true">
            <h5 class="modal-title" id="exampleModalCenteredScrollableTitle">Modal title</h5>
        </model-header>
        <model-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 prefedined 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>
        </model-body>
        <model-footer>
            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
            <button type="button" class="btn btn-primary">Save changes</button>
        </model-footer>
    </modal>

Tooltips and popovers

Tooltips and popovers can be placed within modals as needed. When modals are closed, any tooltips and popovers within are also automatically dismissed.

<model-body>
        <h5>Popover in a modal</h5>
            <p>This <a href="#" role="button" class="btn btn-secondary popover-test" title="" data-bs-content="Popover body content is set in this attribute." data-bs-container="#exampleModalPopovers" data-bs-original-title="Popover title">button</a> triggers a popover on click.</p>
            <hr>
            <h5>Tooltips in a modal</h5>
            <p><a href="#" class="tooltip-test" title="" data-bs-container="#exampleModalPopovers" data-bs-original-title="Tooltip">This link</a> and <a href="#" class="tooltip-test" title="" data-bs-container="#exampleModalPopovers" data-bs-original-title="Tooltip">that link</a> have tooltips on hover.</p>
    </model-body>

Using the grid

Utilize the Bootstrap grid system within a modal by nesting .container-fluid within the .modal-body. Then, use the normal grid system classes as you would anywhere else.

<model-body>
        <div class="container-fluid bd-example-row">
            <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>
    </model-body>

Varying modal content

Have a bunch of buttons that all trigger the same modal with slightly different contents? Use event.relatedTarget and HTML data-bs-* attributes to vary the contents of the modal depending on which button was clicked.

   
<div class="bd-content ">
    <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal1" data-bs-whatever="@mdo">Open modal for @mdo</button>
    <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal1" data-bs-whatever="@fat">Open modal for @fat</button>
    <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal1" data-bs-whatever="@getbootstrap">Open modal for @getbootstrap</button>
</div>
<modal mainClass="fade" :tabindex="-1" id="exampleModal1" ariaLabelled="exampleModalLabel" :ariaHidden="true" style="display: none;">
    <model-header :dismissable="true">
        <h5 class="modal-title" id="exampleModalLabel">New message to @mdo</h5>
    </model-header>
    <model-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>
    </model-body>
    <model-footer>
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
    </model-footer>
</modal>

Toggle between modals

Toggle between multiple modals with some clever placement of the data-bs-target and data-bs-toggle attributes. For example, you could toggle a password reset modal from within an already open sign in modal. Please note multiple modals cannot be open at the same time—this method simply toggles between two separate modals.

<modal mainClass="fade" :tabindex="-1" id="exampleModalToggle" ariaLabelled="exampleModalToggleLabel" :ariaHidden="true" style="display: none;" dialogClass="modal-dialog-centered">
    <model-header :dismissable="true">
        <h5 class="modal-title" id="exampleModalToggleLabel">Modal 1</h5>
    </model-header>
    <model-body>
        Show a second modal and hide this one with the button below.
    </model-body>
    <model-footer>
        <button class="btn btn-primary" data-bs-target="#exampleModalToggle2" data-bs-toggle="modal" data-bs-dismiss="modal">Open second modal</button>
    </model-footer>
</modal>
<modal mainClass="fade" :tabindex="-1" id="exampleModalToggle2" ariaLabelled="exampleModalToggleLabel2" :ariaHidden="true" style="display: none;" dialogClass="modal-dialog-centered">
    <model-header :dismissable="true">
        <h5 class="modal-title" id="exampleModalToggleLabel2">Modal 2</h5>
    </model-header>
    <model-body>
        Hide this modal and show the first with the button below.
    </model-body>
    <model-footer>
        <button class="btn btn-primary" data-bs-target="#exampleModalToggle" data-bs-toggle="modal" data-bs-dismiss="modal">Back to first</button>
    </model-footer>
</modal>
<div class="bd-content">
    <a class="btn btn-primary" data-bs-toggle="modal" href="#exampleModalToggle" role="button">Open first modal</a>
</div>

Change animation

The $modal-fade-transform variable determines the transform state of .modal-dialog before the modal fade-in animation, the $modal-show-transform variable determines the transform of .modal-dialog at the end of the modal fade-in animation.

Remove animation

For modals that simply appear rather than fade in to view, remove the .fade class from your modal markup.

<modal :tabindex="-1">
    ...
</modal>