Skip to content

Commit ab2ceab

Browse files
committed
fix(material/slide-toggle): use css var for disabled label color (#28471)
* fix(material/slide-toggle): use css var for disabled label color * Create a css var to allow teams to override the label text color of a disabled switch * fixup! fix(material/slide-toggle): use css var for disabled label color * fixup! fix(material/slide-toggle): use css var for disabled label color (cherry picked from commit 76f43e4)
1 parent d7f26c3 commit ab2ceab

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/material/slide-toggle/_slide-toggle-theme.scss

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@
3131
@include mdc-switch-theme.theme($mdc-switch-color-tokens);
3232
@include mdc-form-field-theme.theme(tokens-mdc-form-field.get-color-tokens($theme));
3333

34-
// MDC should set the disabled color on the label, but doesn't, so we do it here instead.
35-
.mdc-switch--disabled + label {
36-
color: inspection.get-theme-color($theme, foreground, disabled-text);
37-
}
34+
// TODO(wagnermaciel): Use our token system to define this css variable.
35+
--mdc-switch-disabled-label-text-color: #{inspection.get-theme-color(
36+
$theme,
37+
foreground,
38+
disabled-text
39+
)};
3840

3941
// Change the color palette related tokens to accent or warn if applicable
4042
&.mat-accent {

src/material/slide-toggle/slide-toggle.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
// Add the MDC switch static styles.
1414
@include mdc-switch.static-styles-without-ripple();
1515

16+
// TODO(wagnermaciel): Use our custom token system to emit this css rule.
17+
.mat-mdc-slide-toggle .mdc-switch--disabled + label {
18+
color: var(--mdc-switch-disabled-label-text-color);
19+
}
20+
1621
.mdc-switch {
1722
// Add the official slots for the MDC switch
1823
@include mdc-switch-theme.theme-styles($mdc-switch-token-slots);

0 commit comments

Comments
 (0)