Skip to content

Commit e486365

Browse files
authored
fix(material-experimental/mdc-chips): make it easier to customize chip typography (#24632)
Moves the typography styles of the chip to the root of the component so that it's easier to customize, similar to the non-MDC version.
1 parent 82359e0 commit e486365

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/material-experimental/mdc-chips/_chips-theme.scss

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
@use '@material/chips/chip' as mdc-chip;
21
@use '@material/chips/chip-theme' as mdc-chip-theme;
32
@use '@material/chips/chip-set' as mdc-chip-set;
43
@use '@material/theme/theme-color' as mdc-theme-color;
54
@use '@material/theme/color-palette' as mdc-color-palette;
5+
@use '@material/typography' as mdc-typography;
66
@use 'sass:color';
77
@use 'sass:map';
88
@use '../mdc-helpers/mdc-helpers';
@@ -80,7 +80,12 @@
8080
theming.get-typography-config($config-or-theme));
8181
@include mdc-chip-set.core-styles($query: mdc-helpers.$mat-typography-styles-query);
8282
@include mdc-helpers.mat-using-mdc-typography($config) {
83-
@include mdc-chip.without-ripple-styles($query: mdc-helpers.$mat-typography-styles-query);
83+
// Note that we don't go through MDC's typography mixin, because it assigns the styles to
84+
// an inner element which makes it difficult for clients to customize. Instead we apply the
85+
// same styles ourselves to the root.
86+
.mat-mdc-standard-chip {
87+
@include mdc-typography.typography(body2, $query: mdc-helpers.$mat-typography-styles-query);
88+
}
8489
}
8590
}
8691

src/material-experimental/mdc-chips/chip.scss

+8
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@
7373
width: 100%;
7474
}
7575

76+
// This element can be placed on a `button` node which usually has some user agent styles.
77+
// Reset the font so that the typography from the root element can propagate down.
78+
.mdc-evolution-chip__action--primary {
79+
font: inherit;
80+
letter-spacing: inherit;
81+
white-space: inherit;
82+
}
83+
7684
// MDC sizes and positions this element using `width`, `height` and `padding`.
7785
// This usually works, but it's common for apps to add `box-sizing: border-box`
7886
// to all elements on the page which can cause the graphic to be clipped.

0 commit comments

Comments
 (0)