Skip to content

Commit 76f43e4

Browse files
authored
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
1 parent 3ccee77 commit 76f43e4

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
@@ -39,10 +39,12 @@
3939
@include mdc-switch-theme.theme($mdc-switch-color-tokens);
4040
@include mdc-form-field-theme.theme(tokens-mdc-form-field.get-color-tokens($theme));
4141

42-
// MDC should set the disabled color on the label, but doesn't, so we do it here instead.
43-
.mdc-switch--disabled + label {
44-
color: inspection.get-theme-color($theme, foreground, disabled-text);
45-
}
42+
// TODO(wagnermaciel): Use our token system to define this css variable.
43+
--mdc-switch-disabled-label-text-color: #{inspection.get-theme-color(
44+
$theme,
45+
foreground,
46+
disabled-text
47+
)};
4648

4749
// Change the color palette related tokens to accent or warn if applicable
4850
&.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)