Skip to content

Commit 875c624

Browse files
committed
fix(material-experimental/mdc-button): density styles being overwritten by structural styles
The button's density styles currently have the same specificity as the structural styles which means that they'll usually be overwritten, unless they're nested inside another selector. These changes add more specificity so that the density always has precedence. Fixes #22728.
1 parent 94076af commit 875c624

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/material-experimental/mdc-button/_button-theme.scss

+4-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@
158158
.mat-mdc-raised-button,
159159
.mat-mdc-unelevated-button,
160160
.mat-mdc-outlined-button {
161-
@include mdc-button-theme.density($density-scale, $query: mdc-helpers.$mat-base-styles-query);
161+
// Use `mat-mdc-button-base` to increase the specificity over the button's structural styles.
162+
&.mat-mdc-button-base {
163+
@include mdc-button-theme.density($density-scale, $query: mdc-helpers.$mat-base-styles-query);
164+
}
162165
}
163166
}
164167

src/material-experimental/mdc-button/_icon-button-theme.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656

5757
@mixin density($config-or-theme) {
5858
$density-scale: theming.get-density-config($config-or-theme);
59-
.mat-mdc-icon-button {
59+
// Use `mat-mdc-button-base` to increase the specificity over the button's structural styles.
60+
.mat-mdc-icon-button.mat-mdc-button-base {
6061
@include mdc-icon-button.density($density-scale, $query: mdc-helpers.$mat-base-styles-query);
6162
}
6263
}

0 commit comments

Comments
 (0)