Skip to content

Commit aec28e2

Browse files
committed
fix(material/button): inherit button shape in focus indicator (#31065)
Updates the button's focus indicator to inherit the shape of its button which looks better than the current approach. (cherry picked from commit d27f793)
1 parent 10a6ea4 commit aec28e2

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/material/button/_button-base.scss

+9-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// color and opacity for states like hover, active, and focus. Additionally, adds styles to the
77
// ripple and state container so that they fill the button, match the border radius, and avoid
88
// pointer events.
9-
@mixin mat-private-button-interactive() {
9+
@mixin mat-private-button-interactive($focus-indicator-inherits-shape: true) {
1010
-webkit-tap-highlight-color: transparent;
1111

1212
// The ripple container should match the bounds of the entire button.
@@ -50,10 +50,18 @@
5050
// The focus indicator should match the bounds of the entire button.
5151
.mat-focus-indicator {
5252
@include layout-common.fill();
53+
54+
@if ($focus-indicator-inherits-shape) {
55+
border-radius: inherit;
56+
}
5357
}
5458

5559
&:focus > .mat-focus-indicator::before {
5660
content: '';
61+
62+
@if ($focus-indicator-inherits-shape) {
63+
border-radius: inherit;
64+
}
5765
}
5866
}
5967

src/material/button/fab.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
transform 270ms 0ms cubic-bezier(0, 0, 0.2, 1);
2727
flex-shrink: 0; // Prevent the button from shrinking since it's always supposed to be a circle.
2828

29-
@include button-base.mat-private-button-interactive();
29+
// Due to the shape of the FAB, inheriting the shape looks off. Disable it explicitly.
30+
@include button-base.mat-private-button-interactive($focus-indicator-inherits-shape: false);
3031
@include style-private.private-animation-noop();
3132

3233
&::before {

0 commit comments

Comments
 (0)