diff --git a/scss/_modal.scss b/scss/_modal.scss index 06ab5644d..2b44dc46d 100644 --- a/scss/_modal.scss +++ b/scss/_modal.scss @@ -233,3 +233,50 @@ } } } + +.modal-left, +.modal-right { + .modal-dialog { + width: $modal-sidebar-width; + max-width: $modal-sidebar-max-width; + height: 100%; + margin: 0; + transform: translate(0); + @include transition(transform .2s); + } + + .modal-content { + height: inherit; + border: 0; + @include border-radius(0); + } + + .modal-body { + overflow-y: auto; + } + + &.modal.fade { + .modal-dialog { + transform: translateX(0); + } + } + &.modal.show { + .modal-dialog { + transform: none; + } + } +} + +.modal.modal-left { + .modal-dialog { + margin-right: auto; + transform: translateX(-100%); + } +} + +.modal.modal-right { + .modal-dialog { + margin-left: auto; + transform: translateX(100%); + } +} diff --git a/scss/_variables.scss b/scss/_variables.scss index d9acaca98..17747c600 100644 --- a/scss/_variables.scss +++ b/scss/_variables.scss @@ -1162,6 +1162,9 @@ $modal-md: 500px !default; $modal-lg: 800px !default; $modal-xl: 1140px !default; +$modal-sidebar-width: 350px !default; +$modal-sidebar-max-width: 80% !default; + $modal-fade-transform: translate(0, -50px) !default; $modal-show-transform: none !default; $modal-transition: transform .3s ease-out !default; diff --git a/site/content/docs/5.0/components/modal.md b/site/content/docs/5.0/components/modal.md index 7fd5ec617..22b258d2b 100644 --- a/site/content/docs/5.0/components/modal.md +++ b/site/content/docs/5.0/components/modal.md @@ -186,7 +186,6 @@ When backdrop is set to static, the modal will not close when clicking outside i ``` - ### 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. @@ -347,6 +346,166 @@ Add `.modal-dialog-centered` to `.modal-dialog` to vertically center the modal. ``` +## Sidebar modals + +Convert modals into offcanvas sidebar components with the addition of `.modal-left` or `.modal-right`. These classes override the modal's default position, sizing, and transitions to make them appear as offcanvas drawers for content, shopping carts, navigation, and more. + +With these two demos, we've removed our optional `.modal-footer`s, but you can add them back. You can also add any custom content within the modal, or change the default appearance, as you need. + +### Left modal + +Our first demo is for `.modal-left`, which also has a vertical `.nav-pills` component in it. If you include `.fade` on the `.modal`, the modal and backdrop will slowly fade into view instead of sliding into the viewport from offscreen. + +
+ + + +