diff --git a/scss/_modal.scss b/scss/_modal.scss index ee58032ee811..671dc35e54fd 100644 --- a/scss/_modal.scss +++ b/scss/_modal.scss @@ -32,6 +32,13 @@ --#{$prefix}modal-footer-border-width: #{$modal-footer-border-width}; // scss-docs-end modal-css-vars + // Modal width breakpoints + // These can be customized using CSS variables + --#{$prefix}modal-sm-width: #{$modal-sm}; + --#{$prefix}modal-md-width: #{$modal-md}; + --#{$prefix}modal-lg-width: #{$modal-lg}; + --#{$prefix}modal-xl-width: #{$modal-xl}; + position: fixed; top: 0; left: 0; @@ -204,6 +211,32 @@ } } +// Media Queries for new CSS Breakpoints +@include media-breakpoint-up(sm) { + .modal-dialog { + max-width: var(--#{$prefix}modal-md-width); + margin-right: auto; + margin-left: auto; + } + + .modal-sm { + max-width: var(--#{$prefix}modal-sm-width); + } +} + +@include media-breakpoint-up(lg) { + .modal-lg, + .modal-xl { + max-width: var(--#{$prefix}modal-lg-width); + } +} + +@include media-breakpoint-up(xl) { + .modal-xl { + max-width: var(--#{$prefix}modal-xl-width); + } +} + // scss-docs-start modal-fullscreen-loop @each $breakpoint in map-keys($grid-breakpoints) { $infix: breakpoint-infix($breakpoint, $grid-breakpoints); diff --git a/site/content/docs/5.3/components/modal.md b/site/content/docs/5.3/components/modal.md index e00931e8162e..6fe2677e0aa9 100644 --- a/site/content/docs/5.3/components/modal.md +++ b/site/content/docs/5.3/components/modal.md @@ -869,3 +869,71 @@ myModalEl.addEventListener('hidden.bs.modal', event => { // do something... }) ``` + +## New Custom Modal Width Breakpoints + +You can now set custom width breakpoints for modals using CSS variables. This allows you to define different modal sizes for different screen widths, directly in your CSS. + +### Custom Properties for Modal Sizes + +Here are the available CSS custom properties for modals: + +- `--bs-modal-sm-width`: Custom width for small modals (default `300px`). +- `--bs-modal-md-width`: Custom width for medium modals (default `500px`). +- `--bs-modal-lg-width`: Custom width for large modals (default `800px`). +- `--bs-modal-xl-width`: Custom width for extra-large modals (default `1140px`). + +#### Example Usage: + +In your custom CSS: + +```css +:root { + --bs-modal-sm-width: 400px; + --bs-modal-md-width: 600px; + --bs-modal-lg-width: 900px; + --bs-modal-xl-width: 1200px; +} +``` +The Example of the Modal: + +
+ +
+ + +```html + + + + +``` +