Skip to content

Commit ff5aa09

Browse files
committed
fix(material/button): inherit button shape in focus indicator
Updates the button's focus indicator to inherit the shape of its button which looks better than the current approach.
1 parent ce145fa commit ff5aa09

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/material/button/_button-base.scss

+11-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,6 +50,16 @@
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+
}
57+
}
58+
59+
@if ($focus-indicator-inherits-shape) {
60+
.mat-focus-indicator::before {
61+
border-radius: inherit;
62+
}
5363
}
5464

5565
&:focus > .mat-focus-indicator::before {

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)