Skip to content

Commit

Permalink
fix(material/slide-toggle): use css var for disabled label color (#28471
Browse files Browse the repository at this point in the history
)

* 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)
  • Loading branch information
wagnermaciel committed Jan 24, 2024
1 parent d7f26c3 commit ab2ceab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/material/slide-toggle/_slide-toggle-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
@include mdc-switch-theme.theme($mdc-switch-color-tokens);
@include mdc-form-field-theme.theme(tokens-mdc-form-field.get-color-tokens($theme));

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

// Change the color palette related tokens to accent or warn if applicable
&.mat-accent {
Expand Down
5 changes: 5 additions & 0 deletions src/material/slide-toggle/slide-toggle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
// Add the MDC switch static styles.
@include mdc-switch.static-styles-without-ripple();

// TODO(wagnermaciel): Use our custom token system to emit this css rule.
.mat-mdc-slide-toggle .mdc-switch--disabled + label {
color: var(--mdc-switch-disabled-label-text-color);
}

.mdc-switch {
// Add the official slots for the MDC switch
@include mdc-switch-theme.theme-styles($mdc-switch-token-slots);
Expand Down

0 comments on commit ab2ceab

Please sign in to comment.