]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Support input groups in floating forms (#36759)
authorMark Otto <markd.otto@gmail.com>
Mon, 18 Jul 2022 03:50:41 +0000 (20:50 -0700)
committerGitHub <noreply@github.com>
Mon, 18 Jul 2022 03:50:41 +0000 (20:50 -0700)
* Support input groups in floating forms

* Update bundlewatch

Co-authored-by: 719media <ben@719media.com>
.bundlewatch.config.json
scss/forms/_input-group.scss
site/content/docs/5.2/forms/floating-labels.md

index 7b5017ac1c5fbf5c93d9919bfcdbb3d77be0424a..c89a19e471d558cd982ced55100c0a8339ad8f95 100644 (file)
@@ -30,7 +30,7 @@
     },
     {
       "path": "./dist/css/bootstrap.min.css",
-      "maxSize": "26.5 kB"
+      "maxSize": "26.75 kB"
     },
     {
       "path": "./dist/js/bootstrap.bundle.js",
index 140052936cbb7d02405f3b774fceefe142ea2952..83d52c51e088c853a1d2d16d56165ac01b9ff406 100644 (file)
@@ -10,7 +10,8 @@
   width: 100%;
 
   > .form-control,
-  > .form-select {
+  > .form-select,
+  > .form-floating {
     position: relative; // For focus state's z-index
     flex: 1 1 auto;
     width: 1%;
@@ -19,7 +20,8 @@
 
   // Bring the "active" form control to the top of surrounding elements
   > .form-control:focus,
-  > .form-select:focus {
+  > .form-select:focus,
+  > .form-floating:focus-within {
     z-index: 3;
   }
 
 // stylelint-disable-next-line no-duplicate-selectors
 .input-group {
   &:not(.has-validation) {
-    > :not(:last-child):not(.dropdown-toggle):not(.dropdown-menu),
-    > .dropdown-toggle:nth-last-child(n + 3) {
+    > :not(:last-child):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating),
+    > .dropdown-toggle:nth-last-child(n + 3),
+    > .form-floating:not(:last-child) > .form-control,
+    > .form-floating:not(:last-child) > .form-select {
       @include border-end-radius(0);
     }
   }
 
   &.has-validation {
-    > :nth-last-child(n + 3):not(.dropdown-toggle):not(.dropdown-menu),
-    > .dropdown-toggle:nth-last-child(n + 4) {
+    > :nth-last-child(n + 3):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating),
+    > .dropdown-toggle:nth-last-child(n + 4),
+    > .form-floating:nth-last-child(n + 3) > .form-control,
+    > .form-floating:nth-last-child(n + 3) > .form-select {
       @include border-end-radius(0);
     }
   }
     $validation-messages: $validation-messages + ":not(." + unquote($state) + "-tooltip)" + ":not(." + unquote($state) + "-feedback)";
   }
 
-  > :not(:first-child):not(.dropdown-menu)#{$validation-messages} {
+  > :not(:first-child):not(.dropdown-menu):not(.form-floating)#{$validation-messages},
+  > .form-floating:not(:first-child) > .form-control,
+  > .form-floating:not(:first-child) > .form-select {
     margin-left: -$input-border-width;
     @include border-start-radius(0);
   }
index a19bbdbfe9c9ee1d459657fedf41231de5cc3049..9ec4fcd2faa86f6b21ae8e932fdc998e25649558 100644 (file)
@@ -90,6 +90,35 @@ Floating labels also support `.form-control-plaintext`, which can be helpful for
 </div>
 {{< /example >}}
 
+## Input groups
+
+Floating labels also support `.input-group`.
+
+{{< example >}}
+<div class="input-group mb-3">
+  <span class="input-group-text">@</span>
+  <div class="form-floating">
+    <input type="text" class="form-control" id="floatingInputGroup1" placeholder="Username">
+    <label for="floatingInputGroup1">Username</label>
+  </div>
+</div>
+{{< /example >}}
+
+When using `.input-group` and `.form-floating` along with form validation, the `-feedback` should be placed outside of the `.form-floating`, but inside of the `.input-group`. This means that the feedback will need to be shown using javascript.
+
+{{< example >}}
+<div class="input-group has-validation">
+  <span class="input-group-text">@</span>
+  <div class="form-floating is-invalid">
+    <input type="text" class="form-control is-invalid" id="floatingInputGroup2" placeholder="Username" required>
+    <label for="floatingInputGroup2">Username</label>
+  </div>
+  <div class="invalid-feedback">
+    Please choose a username.
+  </div>
+</div>
+{{< /example >}}
+
 ## Layout
 
 When working with the Bootstrap grid system, be sure to place form elements within column classes.