]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Update Alert and tweak some divider styles (#41954)
authorMark Otto <markd.otto@gmail.com>
Fri, 19 Dec 2025 06:31:46 +0000 (22:31 -0800)
committerMark Otto <markdotto@gmail.com>
Fri, 9 Jan 2026 04:14:08 +0000 (20:14 -0800)
* Redo some alerts CSS, fix hr and vr components

* fix link

scss/_alert.scss
scss/_root.scss
scss/_variables.scss
scss/content/_prose.scss
scss/content/_reboot.scss
scss/helpers/_vr.scss
scss/tests/modules/_configuration.test.scss
site/src/content/docs/components/alert.mdx
site/src/scss/_component-examples.scss
site/src/scss/_details.scss

index 7af4a8d83f04782fe0a9459cbcfafccafb282523..aa393707dce80de77a96216e01374e3d03406fdf 100644 (file)
@@ -5,39 +5,39 @@
 @use "mixins/border-radius" as *;
 
 // scss-docs-start alert-variables
+$alert-gap:                     $spacer * .75 !default;
 $alert-padding-y:               $spacer !default;
 $alert-padding-x:               $spacer !default;
-$alert-margin-bottom:           1rem !default;
 $alert-border-radius:           var(--border-radius) !default;
-$alert-link-font-weight:        $font-weight-bold !default;
+$alert-link-font-weight:        $font-weight-semibold !default;
 $alert-border-width:            var(--border-width) !default;
-$alert-dismissible-padding-r:   $alert-padding-x * 3 !default; // 3x covers width of x plus default padding on either side
 // scss-docs-end alert-variables
 
 @layer components {
   .alert {
     // scss-docs-start alert-css-vars
-    --alert-bg: var(--theme-bg-subtle, transparent);
+    --alert-gap: #{$alert-gap};
+    --alert-bg: var(--theme-bg-subtle, var(--bg-1));
     --alert-padding-x: #{$alert-padding-x};
     --alert-padding-y: #{$alert-padding-y};
-    --alert-margin-bottom: #{$alert-margin-bottom};
     --alert-color: var(--theme-text, inherit);
-    --alert-border-color: transparent;
-    --alert-border: #{$alert-border-width} solid var(--theme-border, var(--alert-border-color));
+    --alert-border-color: var(--theme-border, var(--border-color));
+    --alert-border: #{$alert-border-width} solid var(--alert-border-color);
     --alert-border-radius: #{$alert-border-radius};
     --alert-link-color: inherit;
+    --hr-border-color: var(--theme-border, var(--border-color));
     // scss-docs-end alert-css-vars
 
-    position: relative;
+    display: flex;
+    gap: var(--alert-gap);
+    align-items: start;
     padding: var(--alert-padding-y) var(--alert-padding-x);
-    // margin-bottom: var(--alert-margin-bottom);
     color: var(--alert-color);
     background-color: var(--alert-bg);
     border: var(--alert-border);
     @include border-radius(var(--alert-border-radius));
   }
 
-  // Headings for larger alerts
   .alert-heading {
     // Specified to prevent conflicts of changing $headings-color
     color: inherit;
@@ -48,22 +48,4 @@ $alert-dismissible-padding-r:   $alert-padding-x * 3 !default; // 3x covers widt
     font-weight: $alert-link-font-weight;
     color: var(--alert-link-color);
   }
-
-
-  // Dismissible alerts
-  //
-  // Expand the right padding and account for the close button's positioning.
-
-  .alert-dismissible {
-    padding-inline-end: $alert-dismissible-padding-r;
-
-    // Adjust close link position
-    .btn-close {
-      position: absolute;
-      inset-block-start: 0;
-      inset-inline-end: 0;
-      z-index: $stretched-link-z-index + 1;
-      padding: $alert-padding-y * 1.25 $alert-padding-x;
-    }
-  }
 }
index 2a582c5a05677b2d8c351b418fdcc30192659cba..2924962743966b763e78db78234fa59e019e2ab9 100644 (file)
 
   --heading-color: #{$headings-color};
 
+  --hr-border-color: var(--border-color);
+
   --link-color: light-dark(var(--primary-base), var(--primary-text));
   --link-decoration: #{$link-decoration};
   --link-hover-color: color-mix(in oklch, var(--link-color) 90%, #000);
index 16c891d747f0d8756464837296bc22b25fc5f2f7..5ff0a10a28c66485b784c0dcb9b1fa83a44a1173 100644 (file)
@@ -319,11 +319,6 @@ $blockquote-footer-color:     var(--gray-600) !default;
 $blockquote-footer-font-size: $small-font-size !default;
 
 $hr-margin-y:                 $spacer !default;
-$hr-color:                    inherit !default;
-
-$hr-border-color:             null !default; // Allows for inherited colors
-$hr-border-width:             var(--border-width) !default;
-$hr-opacity:                  .25 !default;
 
 // scss-docs-start vr-variables
 $vr-border-width:             var(--border-width) !default;
index cbb7fa53540b177e18d8486b8c623b75f7f6e9bd..10215f17618981bec4e687848037c0084fcd266f 100644 (file)
@@ -43,7 +43,7 @@
     hr {
       margin: calc(var(--content-gap) * 1.5) 0;
       border: 0;
-      border-block-start: 1px solid var(--border-color);
+      border-block-start: var(--border-width) solid var(--hr-border-color);
     }
 
     h1,
     h4,
     h5,
     h6 {
-      margin-top: 0;
-      margin-bottom: calc(var(--content-gap) / -2);
-      font-weight: 500;
-      line-height: 1.25;
-
-      code {
-        font-weight: 600;
-        color: inherit;
+      &:not([class]) {
+        margin-top: 0;
+        margin-bottom: calc(var(--content-gap) / -2);
+        font-weight: 500;
+        line-height: 1.25;
+
+        code {
+          font-weight: 600;
+          color: inherit;
+        }
       }
     }
 
index ac2197eea44564576dc8e8f1870225dee64fcdac..0162321ad39a6aaabe9c0683b54c664334f4f98a 100644 (file)
   }
   // scss-docs-end reboot-body-rules
 
-
-  // Content grouping
-  //
-  // 1. Reset Firefox's gray color
-
   hr {
     margin: $hr-margin-y 0;
-    color: $hr-color; // 1
     border: 0;
-    border-block-start: $hr-border-width solid $hr-border-color;
-    opacity: $hr-opacity;
+    border-block-start: var(--border-width) solid var(--hr-border-color);
   }
 
 
index 0dfef6afeb76be0d26047ecb3ccb3a1db3df35b4..6ffa4a0f337c241b7659d103f49406a1bcaf1e8d 100644 (file)
@@ -6,7 +6,6 @@
     align-self: stretch;
     width: $vr-border-width;
     min-height: 1em;
-    background-color: currentcolor;
-    opacity: $hr-opacity;
+    background-color: var(--border-color);
   }
 }
index 8569944ceda5fd6cc909dd7644d04f67181ef175..b8a4492e2c056aaad1e0781411b92c4e94a5ffdc 100644 (file)
@@ -1,6 +1,5 @@
 // Test @use with configuration syntax using a single module instance
 @use "../../alert" as * with (
-  $alert-margin-bottom: 3rem,
   $alert-link-font-weight: 800
 );
 @use "../../variables" as *;
@@ -13,14 +12,12 @@ $true-terminal-output: false;
       @include assert() {
         @include output() {
           .test {
-            margin-bottom: $alert-margin-bottom;
             font-weight: $alert-link-font-weight;
           }
         }
 
         @include expect() {
           .test {
-            margin-bottom: 3rem;
             font-weight: 800;
           }
         }
index 316a643f99e5003107bf52e5c1bf55527be223f7..89b60b4ca3206fc2b7be069ab02773f3c34b54f5 100644 (file)
@@ -8,9 +8,17 @@ aliases:
 
 import { getData } from '@libs/data'
 
-## Examples
+## Default alert
 
-Alerts are available for any length of text, as well as an optional close button. For proper styling, use one of the eight **required** contextual classes (e.g., `.alert-success`). For inline dismissal, use the [alerts JavaScript plugin](#dismissing).
+Alerts are available for any length of text, as well as an optional close button. Alerts are designed to be used with theme colors, but have neutral fallback colors for when no theme color is applied. For inline dismissal, use the [alerts JavaScript plugin](#dismiss).
+
+<Example code={`<div class="alert" role="alert">
+    A simple alert—check it out!
+  </div>`} />
+
+## Variants
+
+Use any of our variant theme classes for color mode adaptive, contextual styling.
 
 <Example code={getData('theme-colors').map((themeColor) => `<div class="alert theme-${themeColor.name}" role="alert">
     A simple ${themeColor.name} alert—check it out!
@@ -18,7 +26,7 @@ Alerts are available for any length of text, as well as an optional close button
 
 <Details name="warning-color-assistive-technologies" />
 
-### Live example
+## Live example
 
 Click the button below to show an alert (hidden with inline styles to start), then dismiss (and destroy) it with the built-in close button.
 
@@ -29,7 +37,7 @@ We use the following JavaScript to trigger our live alert demo:
 
 <JsDocs name="live-alert" file="site/src/assets/partials/snippets.js" />
 
-### Link color
+## Link color
 
 Use the `.alert-link` utility class to quickly provide matching colored links within any alert.
 
@@ -37,23 +45,25 @@ Use the `.alert-link` utility class to quickly provide matching colored links wi
     A simple ${themeColor.name} alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
   </div>`)} />
 
-### Additional content
+## Additional content
 
 Alerts can also contain additional HTML elements like headings, paragraphs and dividers.
 
 <Example code={`<div class="alert theme-success" role="alert">
-    <h4 class="alert-heading">Well done!</h4>
-    <p>Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.</p>
-    <hr>
-    <p class="mb-0">Whenever you need to, be sure to use margin utilities to keep things nice and tidy.</p>
+    <vstack>
+      <h4 class="alert-heading mb-2">Well done!</h4>
+      <p>Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.</p>
+      <hr class="my-3">
+      <p class="mb-0">Whenever you need to, be sure to use margin utilities to keep things nice and tidy.</p>
+    </vstack>
   </div>`} />
 
-### Icons
+## With icons
 
 Similarly, you can use [flexbox utilities]([[docsref:/utilities/flex]]) and [Bootstrap Icons]([[config:icons]]) to create alerts with icons. Depending on your icons and content, you may want to add more utilities or custom styles.
 
 <Example code={`<div class="alert theme-primary d-flex align-items-center" role="alert">
-    <svg xmlns="http://www.w3.org/2000/svg" class="bi flex-shrink-0 me-2" viewBox="0 0 16 16" role="img" aria-label="Warning:">
+    <svg xmlns="http://www.w3.org/2000/svg" class="bi flex-shrink-0" viewBox="0 0 16 16" role="img" aria-label="Warning:">
       <path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
     </svg>
     <div>
@@ -61,46 +71,7 @@ Similarly, you can use [flexbox utilities]([[docsref:/utilities/flex]]) and [Boo
     </div>
   </div>`} />
 
-Need more than one icon for your alerts? Consider using more Bootstrap Icons and making a local SVG sprite like so to easily reference the same icons repeatedly.
-
-<Example code={`<svg xmlns="http://www.w3.org/2000/svg" class="d-none">
-    <symbol id="check-circle-fill" viewBox="0 0 16 16">
-      <path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"/>
-    </symbol>
-    <symbol id="info-fill" viewBox="0 0 16 16">
-      <path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
-    </symbol>
-    <symbol id="exclamation-triangle-fill" viewBox="0 0 16 16">
-      <path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
-    </symbol>
-  </svg>
-
-  <div class="alert theme-primary d-flex align-items-center" role="alert">
-    <svg class="bi flex-shrink-0 me-2" role="img" aria-label="Info:"><use href="#info-fill"/></svg>
-    <div>
-      An example alert with an icon
-    </div>
-  </div>
-  <div class="alert theme-success d-flex align-items-center" role="alert">
-    <svg class="bi flex-shrink-0 me-2" role="img" aria-label="Success:"><use href="#check-circle-fill"/></svg>
-    <div>
-      An example success alert with an icon
-    </div>
-  </div>
-  <div class="alert theme-warning d-flex align-items-center" role="alert">
-    <svg class="bi flex-shrink-0 me-2" role="img" aria-label="Warning:"><use href="#exclamation-triangle-fill"/></svg>
-    <div>
-      An example warning alert with an icon
-    </div>
-  </div>
-  <div class="alert theme-danger d-flex align-items-center" role="alert">
-    <svg class="bi flex-shrink-0 me-2" role="img" aria-label="Danger:"><use href="#exclamation-triangle-fill"/></svg>
-    <div>
-      An example danger alert with an icon
-    </div>
-  </div>`} />
-
-### Dismissing
+## Dismiss
 
 Using the alert JavaScript plugin, it’s possible to dismiss any alert inline. Here’s how:
 
@@ -112,8 +83,8 @@ Using the alert JavaScript plugin, it’s possible to dismiss any alert inline.
 You can see this in action with a live demo:
 
 <Example code={`<div class="alert theme-warning alert-dismissible fade show" role="alert">
-    <strong>Holy guacamole!</strong> You should check in on some of those fields below.
-    <CloseButton dismiss="alert" />
+    Something’s wrong, check the fields below and try again.
+    <CloseButton dismiss="alert" class="ms-auto" />
   </div>`} />
 
 <Callout type="warning">
index ee76895a11cc7eccc8973d1178d8bfcfc5866536..f5ba91d5febbcc1a70fd48aa52619664873c15c8 100644 (file)
@@ -69,7 +69,6 @@
     display: flow-root;
     padding: var(--bd-example-padding);
     font-size: var(--font-size-base);
-    // margin: 0 ($bd-gutter-x * -.5) 1rem;
     background-color: var(--bs-bg-body);
 
     @include media-breakpoint-up(md) {
index b26d7d62c03af2703a040c6242eb23ebdf0ce47f..d81b2999200f39b5fdd9527a2e39f11e1bab9c4f 100644 (file)
@@ -5,7 +5,6 @@
 
 @layer custom {
   .bd-details {
-    margin-block: 1.25rem;
     font-size: var(--bs-font-size-sm);
     line-height: var(--bs-line-height-sm);
     color: var(--bs-fg-3);