Slideover Bootstrap Modals

Sometimes we don’t want a modal floating in the center of the viewport; sometimes, we want a full-height modal that slides into frame. Luckily, we can write a bit of CSS to extend the Bootstrap modal component to support slideover modals.

We want our slideover modals to have a few key characteristics:

With these goals in mind, I wrote a small bit of CSS to achieve our ends. I used the class name .modal-dialog-slideover, which we can simply add to the element that already has the .modal-dialog class to seamlessly convert a floating modal to a slideout modal. It is a concise 27 lines of SCSS:

.modal-dialog.modal-dialog-slideover {
margin: 0;
margin-left: auto;
max-width: 80%;
 
.modal.fade & {
transform: translate(100%, 0);
}
.modal.fade.show & {
transform: translate(0, 0);
flex-flow: column;
}
& .modal-content {
border: 0;
border-radius: 0;
height: 100vh;
}
& .modal-body {
max-height: 100%;
overflow-y: auto;
}
& .modal-form {
display: flex;
flex-direction: column;
flex: 1 1 auto;
}
}

Here is a CodePen that offers a number of examples of Bootstrap 4 modals converted to slideover modals. Enjoy!

See the Pen Bootstrap 4 SlideOut Modal examples by Stephen Margheim (@smargh) on CodePen.