]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Fix disabled floating labels and add some examples of it in the docs (#37299)
authorJulien Déramond <julien.deramond@orange.com>
Sun, 30 Oct 2022 00:30:59 +0000 (02:30 +0200)
committerGitHub <noreply@github.com>
Sun, 30 Oct 2022 00:30:59 +0000 (20:30 -0400)
* Fix disabled floating labels and add some examples of it in the docs

* Add disabled custom height textarea

scss/forms/_floating-labels.scss
site/content/docs/5.2/forms/floating-labels.md

index 93c1c220512dd3d04d80e90b42719da55d6c286b..e5e35d326de9745b9cb204fcf95b145c800be26c 100644 (file)
@@ -1,7 +1,7 @@
 .form-floating {
   position: relative;
 
-  &::before {
+  &::before:not(.form-control:disabled) {
     position: absolute;
     top: $input-border-width;
     left: $input-border-width;
index 9ec4fcd2faa86f6b21ae8e932fdc998e25649558..6b33fb67ba4544f08abd5b9d3d41dd244860e294 100644 (file)
@@ -75,6 +75,34 @@ Other than `.form-control`, floating labels are only available on `.form-select`
 </div>
 {{< /example >}}
 
+## Disabled
+
+Add the `disabled` boolean attribute on an input, a textarea or a select to give it a grayed out appearance, remove pointer events, and prevent focusing.
+
+{{< example >}}
+<div class="form-floating mb-3">
+  <input type="email" class="form-control" id="floatingInputDisabled" placeholder="name@example.com" disabled>
+  <label for="floatingInputDisabled">Email address</label>
+</div>
+<div class="form-floating mb-3">
+  <textarea class="form-control" placeholder="Leave a comment here" id="floatingTextareaDisabled" disabled></textarea>
+  <label for="floatingTextareaDisabled">Comments</label>
+</div>
+<div class="form-floating mb-3">
+  <textarea class="form-control" placeholder="Leave a comment here" id="floatingTextarea2Disabled" style="height: 100px" disabled></textarea>
+  <label for="floatingTextarea2Disabled">Comments</label>
+</div>
+<div class="form-floating">
+  <select class="form-select" id="floatingSelectDisabled" aria-label="Floating label disabled select example" disabled>
+    <option selected>Open this select menu</option>
+    <option value="1">One</option>
+    <option value="2">Two</option>
+    <option value="3">Three</option>
+  </select>
+  <label for="floatingSelectDisabled">Works with selects</label>
+</div>
+{{< /example >}}
+
 ## Readonly plaintext
 
 Floating labels also support `.form-control-plaintext`, which can be helpful for toggling from an editable `<input>` to a plaintext value without affecting the page layout.