-// stylelint-disable selector-no-qualifying-type
-
//
// Base styles
//
box-shadow: $btn-focus-box-shadow;
}
- // Disabled comes first so active can properly restyle
- &.disabled,
- &:disabled {
- opacity: $btn-disabled-opacity;
- @include box-shadow(none);
- }
-
- &:not(:disabled):not(.disabled):active,
- &:not(:disabled):not(.disabled).active {
+ &:active,
+ &.active {
@include box-shadow($btn-active-box-shadow);
&:focus {
@include box-shadow($btn-focus-box-shadow, $btn-active-box-shadow);
}
}
-}
-// Future-proof disabling of clicks on `<a>` elements
-a.btn.disabled,
-fieldset:disabled a.btn {
- pointer-events: none;
+ &:disabled,
+ &.disabled,
+ fieldset:disabled & { // stylelint-disable-line selector-no-qualifying-type
+ pointer-events: none;
+ opacity: $btn-disabled-opacity;
+ @include box-shadow(none);
+ }
}
&:disabled,
&.disabled {
color: $btn-link-disabled-color;
- pointer-events: none;
}
// No need for an active state here
text-decoration: none;
}
- &:not(:disabled):not(.disabled) {
- &:hover,
- &:focus {
- opacity: .75;
- }
+ &:hover,
+ &:focus {
+ opacity: .75;
+ }
+
+ &:disabled,
+ &.disabled {
+ pointer-events: none;
}
}
border: 0;
appearance: none;
}
-
-// Future-proof disabling of clicks on `<a>` elements
-
-// stylelint-disable-next-line selector-no-qualifying-type
-a.close.disabled {
- pointer-events: none;
-}
&.disabled .page-link {
color: $pagination-disabled-color;
pointer-events: none;
- // Opinionated: remove the "hand" cursor set previously for .page-link
- cursor: auto;
background-color: $pagination-disabled-bg;
border-color: $pagination-disabled-border-color;
}
}
&:disabled {
+ pointer-events: none;
+
&::-webkit-slider-thumb {
background-color: $form-range-thumb-disabled-bg;
}
- &::-webkit-slider-runnable-track {
- cursor: default;
- }
-
&::-moz-range-thumb {
background-color: $form-range-thumb-disabled-bg;
}
- &::-moz-range-track {
- cursor: default;
- }
-
&::-ms-thumb {
background-color: $form-range-thumb-disabled-bg;
}
}
}
- // Disabled comes first so active can properly restyle
- &.disabled,
- &:disabled {
- color: $color;
- background-color: $background;
- border-color: $border;
- // Remove CSS gradients if they're enabled
- @if $enable-gradients {
- background-image: none;
- }
- }
-
- &:not(:disabled):not(.disabled):active,
- &:not(:disabled):not(.disabled).active,
+ &:active,
+ &.active,
.show > &.dropdown-toggle {
color: $active-color;
background-color: $active-background;
}
}
}
+
+ &:disabled,
+ &.disabled {
+ color: $color;
+ background-color: $background;
+ border-color: $border;
+ // Remove CSS gradients if they're enabled
+ @if $enable-gradients {
+ background-image: none;
+ }
+ }
}
@mixin button-outline-variant(
box-shadow: 0 0 0 $btn-focus-width rgba($color, .5);
}
- &.disabled,
- &:disabled {
- color: $color;
- background-color: transparent;
- }
-
- &:not(:disabled):not(.disabled):active,
- &:not(:disabled):not(.disabled).active,
+ &:active,
+ &.active,
.show > &.dropdown-toggle {
color: $active-color;
background-color: $active-background;
}
}
}
+
+ &:disabled,
+ &.disabled {
+ color: $color;
+ background-color: transparent;
+ }
}
// Button sizes
## Disabled state
-Make buttons look inactive by adding the `disabled` boolean attribute to any `<button>` element.
+Make buttons look inactive by adding the `disabled` boolean attribute to any `<button>` element. Disabled buttons have `pointer-events: none` applied to, preventing hover and active states from triggering.
{{< example >}}
<button type="button" class="btn btn-lg btn-primary" disabled>Primary button</button>
group: components
---
-**Be sure to include text for screen readers**, as we've done with `aria-label`.
+**Be sure to include text for screen readers**, as we've done with `aria-label`. Disabled close buttons have `pointer-events: none` applied to, preventing hover and active states from triggering.
{{< example >}}
<button type="button" class="close" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
+
+<button type="button" class="close" disabled aria-label="Close">
+ <span aria-hidden="true">×</span>
+</button>
{{< /example >}}
## Components
+### Disabled states
+
+- Disabled states of the buttons, close button, pagination link & form range now have `pointer-events: none` added. This simplifies our codebase and makes it easier to override active states in CSS. [#29296](https://github.com/twbs/bootstrap/pull/29296).
+
### Alerts
- **Todo:** Remove auto-darkening of `<hr>` elements in `.alert-*` class variants. `<hr>`s use `rgba()` for their color, so these should naturally blend anyway.