]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Fix disabled checkbox toggle buttons (#31651)
authorNikita Mikhaylov <37866244+Psixodelik@users.noreply.github.com>
Tue, 29 Sep 2020 18:49:50 +0000 (21:49 +0300)
committerGitHub <noreply@github.com>
Tue, 29 Sep 2020 18:49:50 +0000 (21:49 +0300)
* fix disabled checkbox toggle buttons

* add disabled checks-radios examples in documentation

Co-authored-by: XhmikosR <xhmikosr@gmail.com>
scss/_variables.scss
scss/forms/_form-check.scss
site/content/docs/5.0/forms/checks-radios.md

index e4d844ffd39675032bd27f060f5eb274ed923d35..3657aa522d4dc48e9de176cfb858aa4ea08ad73b 100644 (file)
@@ -695,6 +695,10 @@ $form-check-input-indeterminate-bg-color:       $component-active-bg !default;
 $form-check-input-indeterminate-border-color:   $form-check-input-indeterminate-bg-color !default;
 $form-check-input-indeterminate-bg-image:       url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><path fill='none' stroke='#{$form-check-input-indeterminate-color}' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/></svg>") !default;
 
+$form-check-input-disabled-opacity:        .5 !default;
+$form-check-label-disabled-opacity:        $form-check-input-disabled-opacity !default;
+$form-check-btn-check-disabled-opacity:    $btn-disabled-opacity !default;
+
 $form-switch-color:               rgba(0, 0, 0, .25) !default;
 $form-switch-width:               2em !default;
 $form-switch-padding-left:        $form-switch-width + .5em !default;
index 84e3e57d1f7fa3ec362971ea29be32ee63052029..16a27246ac5a987153c9af53714ecdccce04749b 100644 (file)
@@ -82,7 +82,7 @@
   &:disabled {
     pointer-events: none;
     filter: none;
-    opacity: .5;
+    opacity: $form-check-input-disabled-opacity;
   }
 
   // Use disabled attribute in addition of :disabled pseudo-class
@@ -90,7 +90,7 @@
   &[disabled],
   &:disabled {
     ~ .form-check-label {
-      opacity: .5;
+      opacity: $form-check-label-disabled-opacity;
     }
   }
 }
   position: absolute;
   clip: rect(0, 0, 0, 0);
   pointer-events: none;
+
+  &[disabled],
+  &:disabled {
+    + .btn {
+      pointer-events: none;
+      filter: none;
+      opacity: $form-check-btn-check-disabled-opacity;
+    }
+  }
 }
index b6914ee42dc6305c8933b07dd0f0406ff49c3377..ae89f5ee34d2f0c9c7bb68e7e780c481c17cdded 100644 (file)
@@ -227,6 +227,11 @@ Create button-like checkboxes and radio buttons by using `.btn` styles rather th
 <label class="btn btn-primary" for="btn-check-2">Checked</label>
 {{< /example >}}
 
+{{< example >}}
+<input type="checkbox" class="btn-check" id="btn-check-3" autocomplete="off" disabled>
+<label class="btn btn-primary" for="btn-check-3">Disabled</label>
+{{< /example >}}
+
 {{< callout info >}}
 Visually, these checkbox toggle buttons are identical to the [button plugin toggle buttons]({{< docsref "/components/buttons#button-plugin" >}}). However, they are conveyed differently by assistive technologies: the checkbox toggles will be announced by screen readers as "checked"/"not checked" (since, despite their appearance, they are fundamentally still checkboxes), whereas the button plugin toggle buttons will be announced as "button"/"button pressed". The choice between these two approaches will depend on the type of toggle you are creating, and whether or not the toggle will make sense to users when announced as a checkbox or as an actual button.
 {{< /callout >}}
@@ -240,8 +245,11 @@ Visually, these checkbox toggle buttons are identical to the [button plugin togg
 <input type="radio" class="btn-check" name="options" id="option2" autocomplete="off">
 <label class="btn btn-secondary" for="option2">Radio</label>
 
-<input type="radio" class="btn-check" name="options" id="option3" autocomplete="off">
-<label class="btn btn-secondary" for="option3">Radio</label>
+<input type="radio" class="btn-check" name="options" id="option3" autocomplete="off" disabled>
+<label class="btn btn-secondary" for="option3">Disabled</label>
+
+<input type="radio" class="btn-check" name="options" id="option4" autocomplete="off">
+<label class="btn btn-secondary" for="option4">Radio</label>
 {{< /example >}}
 
 ### Outlined styles