Skip to content

fix(slide-toggle): no color demarcation in high contrast black mode #12150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions src/lib/slide-toggle/slide-toggle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@ $mat-slide-toggle-bar-track-width: $mat-slide-toggle-bar-width - $mat-slide-togg
border-radius: 50%;

@include mat-elevation(1);

@include cdk-high-contrast {
background: #fff;
border: solid 1px #000;
}
}

// Horizontal bar for the slide-toggle.
Expand All @@ -145,10 +140,6 @@ $mat-slide-toggle-bar-track-width: $mat-slide-toggle-bar-width - $mat-slide-togg
flex-shrink: 0;

border-radius: $mat-slide-toggle-bar-border-radius;

@include cdk-high-contrast {
background: #fff;
}
}

// The slide toggle shows a visually hidden input inside of the component, which is used
Expand Down Expand Up @@ -181,3 +172,28 @@ $mat-slide-toggle-bar-track-width: $mat-slide-toggle-bar-width - $mat-slide-togg
z-index: 1;
pointer-events: none;
}

/** Custom styling to make the slide-toggle usable in high contrast mode. */
@include cdk-high-contrast() {
.mat-slide-toggle-thumb {
background: #fff;
border: 1px solid #000;

.mat-slide-toggle.mat-checked & {
background: #000;
border: 1px solid #fff;
}
}

.mat-slide-toggle-bar {
background: #fff;
}
}

// Since the bar with a white background will be placed on a white background, we need to a black
// border in order to make sure that the bar is visible.
@include cdk-high-contrast(black-on-white) {
.mat-slide-toggle-bar {
border: 1px solid #000;
}
}