From 90cd6f480e51ce4e55963a0690567a6aa428a0a7 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Tue, 16 Dec 2025 11:14:58 -0800 Subject: [PATCH] New dialog size options --- scss/_dialog.scss | 43 ++++++++ site/src/content/docs/components/dialog.mdx | 112 ++++++++++++++++++++ 2 files changed, 155 insertions(+) diff --git a/scss/_dialog.scss b/scss/_dialog.scss index eafc838c35..9989dba3e4 100644 --- a/scss/_dialog.scss +++ b/scss/_dialog.scss @@ -1,5 +1,7 @@ +@use "sass:map"; @use "config" as *; @use "variables" as *; +@use "layout/breakpoints" as *; @use "mixins/border-radius" as *; @use "mixins/box-shadow" as *; @use "mixins/transition" as *; @@ -11,6 +13,9 @@ // scss-docs-start dialog-css-vars $dialog-padding: 1rem !default; $dialog-width: 500px !default; +$dialog-width-sm: 280px !default; +$dialog-width-lg: 800px !default; +$dialog-width-xl: 1140px !default; $dialog-margin: 1.75rem !default; $dialog-color: var(--#{$prefix}fg-body) !default; $dialog-bg: var(--#{$prefix}bg-body) !default; @@ -149,6 +154,44 @@ $dialog-footer-gap: .5rem !default; } } + // Dialog sizes + .dialog-sm { --#{$prefix}dialog-width: #{$dialog-width-sm}; } + .dialog-lg { --#{$prefix}dialog-width: #{$dialog-width-lg}; } + .dialog-xl { --#{$prefix}dialog-width: #{$dialog-width-xl}; } + + // Fullscreen dialog + .dialog-fullscreen { + --#{$prefix}dialog-width: 100vw; + --#{$prefix}dialog-margin: 0; + --#{$prefix}dialog-border-radius: 0; + + width: 100%; + max-width: none; + height: 100%; + max-height: none; + } + + // Responsive fullscreen dialogs + @each $breakpoint in map.keys($grid-breakpoints) { + $infix: breakpoint-infix($breakpoint, $grid-breakpoints); + $postfix: if($infix != "", #{$infix}-down, ""); + + @if $postfix != "" { + @include media-breakpoint-down($breakpoint) { + .dialog-fullscreen#{$postfix} { + --#{$prefix}dialog-width: 100vw; + --#{$prefix}dialog-margin: 0; + --#{$prefix}dialog-border-radius: 0; + + width: 100%; + max-width: none; + height: 100%; + max-height: none; + } + } + } + } + // Dialog header .dialog-header { display: flex; diff --git a/site/src/content/docs/components/dialog.mdx b/site/src/content/docs/components/dialog.mdx index b19c7077be..486c32b21e 100644 --- a/site/src/content/docs/components/dialog.mdx +++ b/site/src/content/docs/components/dialog.mdx @@ -299,6 +299,118 @@ const dialog = new bootstrap.Dialog('#myDialog', { modal: false }) dialog.show() ``` +## Optional sizes + +Dialogs have three optional sizes, available via modifier classes to be placed on a `.dialog`. These sizes kick in at certain breakpoints to avoid horizontal scrollbars on narrower viewports. + + + | Size | Class | Dialog max-width | + | --- | --- | --- | + | Small | `.dialog-sm` | `300px` | + | Default | — | `500px` | + | Large | `.dialog-lg` | `800px` | + | Extra large | `.dialog-xl` | `1140px` | + + + +
+

Extra large dialog

+ +
+
+

This is an extra large dialog using the .dialog-xl class.

+
+
+ + +
+

Large dialog

+ +
+
+

This is a large dialog using the .dialog-lg class.

+
+
+ + +
+

Small dialog

+ +
+
+

This is a small dialog using the .dialog-sm class.

+
+
+ + + Extra large dialog + + +`} /> + +```html +... +... +... +``` + +## Fullscreen dialog + +Use `.dialog-fullscreen` to make the dialog cover the entire viewport. + + +
+

Fullscreen dialog

+ +
+
+

This dialog covers the entire viewport.

+
+ +
+ + + Fullscreen dialog +`} /> + +Responsive fullscreen variants are also available. These make the dialog fullscreen only below a specific breakpoint. + +| Class | Fullscreen below | +| --- | --- | +| `.dialog-fullscreen` | Always | +| `.dialog-fullscreen-sm-down` | `576px` | +| `.dialog-fullscreen-md-down` | `768px` | +| `.dialog-fullscreen-lg-down` | `1024px` | +| `.dialog-fullscreen-xl-down` | `1280px` | +| `.dialog-fullscreen-2xl-down` | `1536px` | + + +
+

Fullscreen below lg

+ +
+
+

This dialog is fullscreen below the lg breakpoint.

+
+ +
+ + + Fullscreen below lg +`} /> + +```html +... +``` + ## JavaScript behavior ### Via data attributes -- 2.47.3