Skip to content

Commit fd7a02f

Browse files
committed
fix(material/slide-toggle): add larger touch target
1 parent 35039f0 commit fd7a02f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/material/slide-toggle/slide-toggle.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
[attr.aria-disabled]="disabled && disabledInteractive ? 'true' : null"
2121
(click)="_handleClick()"
2222
#switch>
23+
<!-- Render this element first so the input is on top. -->
24+
<div class="mat-mdc-slide-toggle-touch-target"></div>
2325
<span class="mdc-switch__track"></span>
2426
<span class="mdc-switch__handle-track">
2527
<span class="mdc-switch__handle">

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,3 +542,20 @@ $fallbacks: m3-slide-toggle.get-tokens();
542542
color: token-utils.slot(slide-toggle-disabled-label-text-color, $fallbacks);
543543
}
544544
}
545+
546+
// Element used to provide a larger tap target for users on touch devices.
547+
.mat-mdc-slide-toggle-touch-target {
548+
position: absolute;
549+
top: 50%;
550+
left: 50%;
551+
height: 48px;
552+
width: 100%;
553+
transform: translate(-50%, -50%);
554+
//display: token-utils.slot(radio-touch-target-display, $fallbacks);
555+
556+
[dir='rtl'] & {
557+
left: auto;
558+
right: 50%;
559+
transform: translate(50%, -50%);
560+
}
561+
}

0 commit comments

Comments
 (0)