Skip to content

Commit 3021cf5

Browse files
authored
fix(material-experimental/mdc-button): density styles being overwritten by structural styles (#22736)
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 a2de246 commit 3021cf5

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,11 @@
196196
.mat-mdc-raised-button,
197197
.mat-mdc-unelevated-button,
198198
.mat-mdc-outlined-button {
199-
@include mdc-button-theme.density($density-scale, $query: mdc-helpers.$mat-base-styles-query);
200-
@include button-theme-private.touch-target-density($density-scale);
199+
// Use `mat-mdc-button-base` to increase the specificity over the button's structural styles.
200+
&.mat-mdc-button-base {
201+
@include mdc-button-theme.density($density-scale, $query: mdc-helpers.$mat-base-styles-query);
202+
@include button-theme-private.touch-target-density($density-scale);
203+
}
201204
}
202205
}
203206

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949

5050
@mixin density($config-or-theme) {
5151
$density-scale: theming.get-density-config($config-or-theme);
52-
.mat-mdc-icon-button {
52+
// Use `mat-mdc-button-base` to increase the specificity over the button's structural styles.
53+
.mat-mdc-icon-button.mat-mdc-button-base {
5354
@include mdc-icon-button.density($density-scale, $query: mdc-helpers.$mat-base-styles-query);
5455
@include button-theme-private.touch-target-density($density-scale);
5556
}

0 commit comments

Comments
 (0)