Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework button focus/active styling, with extra changes for checks/radios #37026

Merged
merged 10 commits into from Sep 4, 2022
27 changes: 17 additions & 10 deletions scss/_buttons.scss
Expand Up @@ -40,18 +40,19 @@
@include box-shadow(var(--#{$prefix}btn-box-shadow));
@include transition($btn-transition);

&:hover {
:not(.btn-check) + &:hover,
&:first-child:hover {
color: var(--#{$prefix}btn-hover-color);
text-decoration: if($link-hover-decoration == underline, none, null);
background-color: var(--#{$prefix}btn-hover-bg);
border-color: var(--#{$prefix}btn-hover-border-color);
}

.btn-check:focus + &,
&:focus {
&:focus-visible {
color: var(--#{$prefix}btn-hover-color);
@include gradient-bg(var(--#{$prefix}btn-hover-bg));
border-color: var(--#{$prefix}btn-hover-border-color);
outline: 0;
// Avoid using mixin so we can pass custom focus shadow properly
@if $enable-shadows {
box-shadow: var(--#{$prefix}btn-box-shadow), var(--#{$prefix}btn-focus-box-shadow);
Expand All @@ -60,14 +61,20 @@
}
}

.btn-check:focus:not(:focus-visible) + &,
&:focus:not(:focus-visible) {
.btn-check:focus-visible + & {
border-color: var(--#{$prefix}btn-hover-border-color);
outline: 0;
// Avoid using mixin so we can pass custom focus shadow properly
@if $enable-shadows {
box-shadow: var(--#{$prefix}btn-box-shadow), var(--#{$prefix}btn-focus-box-shadow);
} @else {
box-shadow: var(--#{$prefix}btn-focus-box-shadow);
}
}

.btn-check:checked + &,
.btn-check:active + &,
&:active,
:not(.btn-check) + &:active,
&:first-child:active,
&.active,
&.show {
color: var(--#{$prefix}btn-active-color);
Expand All @@ -77,7 +84,7 @@
border-color: var(--#{$prefix}btn-active-border-color);
@include box-shadow(var(--#{$prefix}btn-active-shadow));

&:focus {
&:focus-visible {
// Avoid using mixin so we can pass custom focus shadow properly
@if $enable-shadows {
box-shadow: var(--#{$prefix}btn-active-shadow), var(--#{$prefix}btn-focus-box-shadow);
Expand Down Expand Up @@ -162,11 +169,11 @@
text-decoration: $link-decoration;

&:hover,
&:focus {
&:focus-visible {
text-decoration: $link-hover-decoration;
}

&:focus {
&:focus-visible {
color: var(--#{$prefix}btn-color);
}

Expand Down