Modal

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

Basic Example #

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.

Example
<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="sa-close sa-close--modal"
                    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 #

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

Example
<button
    type="button"
    class="btn btn-primary"
    data-bs-toggle="modal"
    data-bs-target="#exampleModal"
>
    Launch demo modal
</button>
<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">
                <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
                <button
                    type="button"
                    class="sa-close sa-close--modal"
                    data-bs-dismiss="modal"
                    aria-label="Close"
                ></button>
            </div>
            <div class="modal-body">
                Woohoo, you&#x27;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 #

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

Example
<button
    type="button"
    class="btn btn-primary"
    data-bs-toggle="modal"
    data-bs-target="#staticBackdrop"
>
    Launch static backdrop modal
</button>
<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">
                <h5 class="modal-title" id="staticBackdropLabel">Modal title</h5>
                <button
                    type="button"
                    class="sa-close sa-close--modal"
                    data-bs-dismiss="modal"
                    aria-label="Close"
                ></button>
            </div>
            <div class="modal-body">
                I will not close if you click outside me. Don&#x27;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 #

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.

Example
<button
    type="button"
    class="btn btn-primary"
    data-bs-toggle="modal"
    data-bs-target="#exampleModalLong"
>
    Launch demo modal
</button>
<div
    class="modal fade"
    id="exampleModalLong"
    tabindex="-1"
    aria-labelledby="exampleModalLongTitle"
    aria-hidden="true"
>
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5>
                <button
                    type="button"
                    class="sa-close sa-close--modal"
                    data-bs-dismiss="modal"
                    aria-label="Close"
                ></button>
            </div>
            <div class="modal-body">
                <p>
                    What follows is just some placeholder text for this modal dialog. You
                    just gotta ignite the light and let it shine! Come just as you are to
                    me. Just own the night like the 4th of July. Infect me with your love
                    and fill me with your poison. Come just as you are to me. End of the
                    rainbow looking treasure.
                </p>
                <p>
                    I can&#x27;t sleep let&#x27;s run away and don&#x27;t ever look back,
                    don&#x27;t ever look back. I can&#x27;t sleep let&#x27;s run away and
                    don&#x27;t ever look back, don&#x27;t ever look back. Yes, we make
                    angels cry, raining down on earth from up above. I&#x27;m walking on
                    air (tonight). Let you put your hands on me in my skin-tight jeans.
                    Stinging like a bee I earned my stripes. I went from zero, to my own
                    hero. Even brighter than the moon, moon, moon. Make &#x27;em go,
                    &#x27;Aah, aah, aah&#x27; as you shoot across the sky-y-y! Why
                    don&#x27;t you let me stop by?
                </p>
                <p>
                    Boom, boom, boom. Never made me blink one time. Yeah, you&#x27;re
                    lucky if you&#x27;re on her plane. Talk about our future like we had a
                    clue. Oh my God no exaggeration. You&#x27;re original, cannot be
                    replaced. The girl&#x27;s a freak, she drive a jeep in Laguna Beach.
                    It&#x27;s no big deal, it&#x27;s no big deal, it&#x27;s no big deal.
                    In another life I would make you stay. I&#x27;m ma get your heart
                    racing in my skin-tight jeans. I wanna walk on your wave length and be
                    there when you vibrate Never made me blink one time.
                </p>
                <p>
                    We&#x27;d keep all our promises be us against the world. In another
                    life I would be your girl. We can dance, until we die, you and I, will
                    be young forever. And on my 18th Birthday we got matching tattoos. So
                    open up your heart and just let it begin. &#x27;Cause she&#x27;s the
                    muse and the artist. She eats your heart out. Like Jeffrey Dahmer
                    (woo). Pop your confetti. (This is how we do) I know one spark will
                    shock the world, yeah yeah. If you only knew what the future holds.
                </p>
                <p>
                    Sipping on Rosé, Silver Lake sun, coming up all lazy. It&#x27;s in the
                    palm of your hand now baby. So we hit the boulevard. So make a wish,
                    I&#x27;ll make it like your birthday everyday. Do you ever feel
                    already buried deep six feet under? It&#x27;s time to bring out the
                    big balloons. You could&#x27;ve been the greatest. Passport stamps,
                    she&#x27;s cosmopolitan. Your kiss is cosmic, every move is magic.
                </p>
                <p>
                    We&#x27;re living the life. We&#x27;re doing it right. Open up your
                    heart. I was tryna hit it and quit it. Her love is like a drug. Always
                    leaves a trail of stardust. The girl&#x27;s a freak, she drive a jeep
                    in Laguna Beach. Fine, fresh, fierce, we got it on lock. All my girls
                    vintage Chanel baby.
                </p>
                <p>
                    Before you met me I was alright but things were kinda heavy.
                    Peach-pink lips, yeah, everybody stares. This is no big deal. Calling
                    out my name. I could have rewrite your addiction. She&#x27;s got that,
                    je ne sais quoi, you know it. Heavy is the head that wears the crown.
                    &#x27;Cause, baby, you&#x27;re a firework. Like thunder gonna shake
                    the ground.
                </p>
                <p>
                    Just own the night like the 4th of July! I&#x27;m gon&#x27; put her in
                    a coma. What you&#x27;re waiting for, it&#x27;s time for you to show
                    it off. Can&#x27;t replace you with a million rings. You open my eyes
                    and I&#x27;m ready to go, lead me into the light. And here you are.
                    I&#x27;m gon&#x27; put her in a coma. Come on, let your colours burst.
                    So cover your eyes, I have a surprise. As I march alone to a different
                    beat. Glitter all over the room pink flamingos in the pool.
                </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 .

Example
<button
    type="button"
    class="btn btn-primary"
    data-bs-toggle="modal"
    data-bs-target="#exampleModalScrollable"
>
    Launch demo modal
</button>
<div
    class="modal fade"
    id="exampleModalScrollable"
    tabindex="-1"
    aria-labelledby="exampleModalScrollableTitle"
    aria-hidden="true"
>
    <div class="modal-dialog modal-dialog-scrollable">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalScrollableTitle">Modal title</h5>
                <button
                    type="button"
                    class="sa-close sa-close--modal"
                    data-bs-dismiss="modal"
                    aria-label="Close"
                ></button>
            </div>
            <div class="modal-body">
                <p>
                    What follows is just some placeholder text for this modal dialog. You
                    just gotta ignite the light and let it shine! Come just as you are to
                    me. Just own the night like the 4th of July. Infect me with your love
                    and fill me with your poison. Come just as you are to me. End of the
                    rainbow looking treasure.
                </p>
                <p>
                    I can&#x27;t sleep let&#x27;s run away and don&#x27;t ever look back,
                    don&#x27;t ever look back. I can&#x27;t sleep let&#x27;s run away and
                    don&#x27;t ever look back, don&#x27;t ever look back. Yes, we make
                    angels cry, raining down on earth from up above. I&#x27;m walking on
                    air (tonight). Let you put your hands on me in my skin-tight jeans.
                    Stinging like a bee I earned my stripes. I went from zero, to my own
                    hero. Even brighter than the moon, moon, moon. Make &#x27;em go,
                    &#x27;Aah, aah, aah&#x27; as you shoot across the sky-y-y! Why
                    don&#x27;t you let me stop by?
                </p>
                <p>
                    Boom, boom, boom. Never made me blink one time. Yeah, you&#x27;re
                    lucky if you&#x27;re on her plane. Talk about our future like we had a
                    clue. Oh my God no exaggeration. You&#x27;re original, cannot be
                    replaced. The girl&#x27;s a freak, she drive a jeep in Laguna Beach.
                    It&#x27;s no big deal, it&#x27;s no big deal, it&#x27;s no big deal.
                    In another life I would make you stay. I&#x27;m ma get your heart
                    racing in my skin-tight jeans. I wanna walk on your wave length and be
                    there when you vibrate Never made me blink one time.
                </p>
                <p>
                    We&#x27;d keep all our promises be us against the world. In another
                    life I would be your girl. We can dance, until we die, you and I, will
                    be young forever. And on my 18th Birthday we got matching tattoos. So
                    open up your heart and just let it begin. &#x27;Cause she&#x27;s the
                    muse and the artist. She eats your heart out. Like Jeffrey Dahmer
                    (woo). Pop your confetti. (This is how we do) I know one spark will
                    shock the world, yeah yeah. If you only knew what the future holds.
                </p>
                <p>
                    Sipping on Rosé, Silver Lake sun, coming up all lazy. It&#x27;s in the
                    palm of your hand now baby. So we hit the boulevard. So make a wish,
                    I&#x27;ll make it like your birthday everyday. Do you ever feel
                    already buried deep six feet under? It&#x27;s time to bring out the
                    big balloons. You could&#x27;ve been the greatest. Passport stamps,
                    she&#x27;s cosmopolitan. Your kiss is cosmic, every move is magic.
                </p>
                <p>
                    We&#x27;re living the life. We&#x27;re doing it right. Open up your
                    heart. I was tryna hit it and quit it. Her love is like a drug. Always
                    leaves a trail of stardust. The girl&#x27;s a freak, she drive a jeep
                    in Laguna Beach. Fine, fresh, fierce, we got it on lock. All my girls
                    vintage Chanel baby.
                </p>
                <p>
                    Before you met me I was alright but things were kinda heavy.
                    Peach-pink lips, yeah, everybody stares. This is no big deal. Calling
                    out my name. I could have rewrite your addiction. She&#x27;s got that,
                    je ne sais quoi, you know it. Heavy is the head that wears the crown.
                    &#x27;Cause, baby, you&#x27;re a firework. Like thunder gonna shake
                    the ground.
                </p>
                <p>
                    Just own the night like the 4th of July! I&#x27;m gon&#x27; put her in
                    a coma. What you&#x27;re waiting for, it&#x27;s time for you to show
                    it off. Can&#x27;t replace you with a million rings. You open my eyes
                    and I&#x27;m ready to go, lead me into the light. And here you are.
                    I&#x27;m gon&#x27; put her in a coma. Come on, let your colours burst.
                    So cover your eyes, I have a surprise. As I march alone to a different
                    beat. Glitter all over the room pink flamingos in the pool.
                </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 #

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

Example
<div class="row g-3">
    <div class="col-auto">
        <button
            type="button"
            class="btn btn-primary"
            data-bs-toggle="modal"
            data-bs-target="#exampleModalCenter"
        >
            Vertically centered modal
        </button>
    </div>
    <div class="col-auto">
        <button
            type="button"
            class="btn btn-primary"
            data-bs-toggle="modal"
            data-bs-target="#exampleModalCenteredScrollable"
        >
            Vertically centered scrollable modal
        </button>
    </div>
</div>
<div
    class="modal fade"
    id="exampleModalCenter"
    tabindex="-1"
    aria-labelledby="exampleModalCenterTitle"
    aria-hidden="true"
>
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalCenterTitle">Modal title</h5>
                <button
                    type="button"
                    class="sa-close sa-close--modal"
                    data-bs-dismiss="modal"
                    aria-label="Close"
                ></button>
            </div>
            <div class="modal-body">
                <p>
                    Placeholder text for this demonstration of a vertically centered modal
                    dialog.
                </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>
<div
    class="modal fade"
    id="exampleModalCenteredScrollable"
    tabindex="-1"
    aria-labelledby="exampleModalCenteredScrollableTitle"
    aria-hidden="true"
>
    <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalCenteredScrollableTitle">
                    Modal title
                </h5>
                <button
                    type="button"
                    class="sa-close sa-close--modal"
                    data-bs-dismiss="modal"
                    aria-label="Close"
                ></button>
            </div>
            <div class="modal-body">
                <p>
                    Placeholder text for this demonstration of a vertically centered modal
                    dialog.
                </p>
                <p>
                    In this case, the dialog has a bit more content, just to show how
                    vertical centering can be added to a scrollable modal.
                </p>
                <p>
                    What follows is just some placeholder text for this modal dialog.
                    Sipping on Rosé, Silver Lake sun, coming up all lazy. It&#x27;s in the
                    palm of your hand now baby. So we hit the boulevard. So make a wish,
                    I&#x27;ll make it like your birthday everyday. Do you ever feel
                    already buried deep six feet under? It&#x27;s time to bring out the
                    big balloons. You could&#x27;ve been the greatest. Passport stamps,
                    she&#x27;s cosmopolitan. Your kiss is cosmic, every move is magic.
                </p>
                <p>
                    We&#x27;re living the life. We&#x27;re doing it right. Open up your
                    heart. I was tryna hit it and quit it. Her love is like a drug. Always
                    leaves a trail of stardust. The girl&#x27;s a freak, she drive a jeep
                    in Laguna Beach. Fine, fresh, fierce, we got it on lock. All my girls
                    vintage Chanel baby.
                </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>

Optional Sizes #

Modals have three optional sizes, available via modifier classes to be placed on a .modal-dialog . These sizes kick in at certain breakpoints to avoid horizontal scrollbars on narrower viewports.

Size Class Modal max-width
Small .modal-sm 300px
Default None 500px
Large .modal-lg 800px
Extra large .modal-xl 1140px

Our default modal without modifier class constitutes the "medium" size modal.

Example
<div class="row g-3">
    <div class="col-auto">
        <button
            type="button"
            class="btn btn-primary"
            data-bs-toggle="modal"
            data-bs-target="#exampleModalXl"
        >
            Extra large modal
        </button>
    </div>
    <div class="col-auto">
        <button
            type="button"
            class="btn btn-primary"
            data-bs-toggle="modal"
            data-bs-target="#exampleModalLg"
        >
            Large modal
        </button>
    </div>
    <div class="col-auto">
        <button
            type="button"
            class="btn btn-primary"
            data-bs-toggle="modal"
            data-bs-target="#exampleModalNl"
        >
            Normal modal
        </button>
    </div>
    <div class="col-auto">
        <button
            type="button"
            class="btn btn-primary"
            data-bs-toggle="modal"
            data-bs-target="#exampleModalSm"
        >
            Small modal
        </button>
    </div>
</div>
<div
    class="modal fade"
    id="exampleModalXl"
    tabindex="-1"
    aria-labelledby="exampleModalXlLabel"
    aria-hidden="true"
>
    <div class="modal-dialog modal-xl">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalXlLabel">Extra large modal</h5>
                <button
                    type="button"
                    class="sa-close sa-close--modal"
                    data-bs-dismiss="modal"
                    aria-label="Close"
                ></button>
            </div>
            <div class="modal-body">...</div>
        </div>
    </div>
</div>
<div
    class="modal fade"
    id="exampleModalLg"
    tabindex="-1"
    aria-labelledby="exampleModalLgLabel"
    aria-hidden="true"
>
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLgLabel">Large modal</h5>
                <button
                    type="button"
                    class="sa-close sa-close--modal"
                    data-bs-dismiss="modal"
                    aria-label="Close"
                ></button>
            </div>
            <div class="modal-body">...</div>
        </div>
    </div>
</div>
<div
    class="modal fade"
    id="exampleModalNl"
    tabindex="-1"
    aria-labelledby="exampleModalNlLabel"
    aria-hidden="true"
>
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalNlLabel">Normal modal</h5>
                <button
                    type="button"
                    class="sa-close sa-close--modal"
                    data-bs-dismiss="modal"
                    aria-label="Close"
                ></button>
            </div>
            <div class="modal-body">...</div>
        </div>
    </div>
</div>
<div
    class="modal fade"
    id="exampleModalSm"
    tabindex="-1"
    aria-labelledby="exampleModalSmLabel"
    aria-hidden="true"
>
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalSmLabel">Small modal</h5>
                <button
                    type="button"
                    class="sa-close sa-close--modal"
                    data-bs-dismiss="modal"
                    aria-label="Close"
                ></button>
            </div>
            <div class="modal-body">...</div>
        </div>
    </div>
</div>