Skip to content

Commit e7508ad

Browse files
JoakimZebicmmalerba
authored andcommitted
fix(material/chips): fix ripple element opacity when using CSS variable theming (#17576)
* Fix (chips): Opacity is not added to the ripple element when using CSS variables to define a custom theme * Fix (chips): Opacity is not added to the ripple element when using CSS variables to define a custom theme * fix(material/chips): fix ripple element opacity when using CSS variable theming
1 parent a3e953e commit e7508ad

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/material/chips/_chips-theme.scss

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,25 @@ $mat-chip-remove-font-size: 18px;
1515
}
1616
}
1717

18+
19+
// Applies the background color for a ripple element.
20+
// If the color value provided is not a Sass color,
21+
// we assume that we've been given a CSS variable.
22+
// Since we can't perform alpha-blending on a CSS variable,
23+
// we instead add the opacity directly to the ripple element.
24+
@mixin _mat-chips-ripple-background($palette, $default-contrast, $opacity) {
25+
$background-color: mat-color($palette, $default-contrast, $opacity);
26+
background-color: $background-color;
27+
@if (type-of($background-color) != color) {
28+
opacity: $opacity;
29+
}
30+
}
31+
1832
@mixin mat-chips-theme-color($palette) {
1933
@include mat-chips-color(mat-color($palette, default-contrast), mat-color($palette));
2034

2135
.mat-ripple-element {
22-
$ripple-opacity: 0.1;
23-
$ripple-color: mat-color($palette, default-contrast, $ripple-opacity);
24-
background-color: $ripple-color;
25-
26-
// If the ripple color is a CSS variable, `mat-color` will
27-
// return a solid color so we have to apply the opacity separately.
28-
@if (type-of($ripple-color) != color) {
29-
opacity: $ripple-opacity;
30-
}
36+
@include _mat-chips-ripple-background($palette, default-contrast, 0.1);
3137
}
3238
}
3339

0 commit comments

Comments
 (0)