3
3
@use ' ../core/tokens/m2/mat/switch' as tokens-mat-switch ;
4
4
@use ' ../core/tokens/m2/mdc/switch' as tokens-mdc-switch ;
5
5
@use ' ../core/tokens/token-utils' ;
6
+ @use ' ../core/style/vendor-prefixes' ;
6
7
7
8
$_mdc-slots : (tokens-mdc-switch .$prefix , tokens-mdc-switch .get-token-slots ());
8
9
$_mat-slots : (tokens-mat-switch .$prefix , tokens-mat-switch .get-token-slots ());
@@ -12,23 +13,14 @@ $_interactive-disabled-selector: '.mat-mdc-slide-toggle-disabled-interactive.mdc
12
13
align-items : center ;
13
14
background : none ;
14
15
border : none ;
15
- cursor : pointer ;
16
16
display : inline-flex ;
17
17
flex-shrink : 0 ;
18
18
margin : 0 ;
19
19
outline : none ;
20
20
overflow : visible ;
21
21
padding : 0 ;
22
22
position : relative ;
23
-
24
- & .mdc-switch--disabled {
25
- cursor : default ;
26
- pointer-events : none ;
27
- }
28
-
29
- & .mat-mdc-slide-toggle-disabled-interactive {
30
- pointer-events : auto ;
31
- }
23
+ z-index : 1 ; // Put the button above the label.
32
24
33
25
@include token-utils .use-tokens ($_mdc-slots ...) {
34
26
@include token-utils .create-token-slot (width , track- width);
@@ -503,8 +495,35 @@ $_interactive-disabled-selector: '.mat-mdc-slide-toggle-disabled-interactive.mdc
503
495
}
504
496
505
497
.mat-mdc-slide-toggle {
498
+ @include vendor-prefixes .user-select (none );
506
499
display : inline-block ;
507
500
-webkit-tap-highlight-color : transparent ;
501
+ cursor : pointer ;
502
+ position : relative ;
503
+
504
+ & :has (.mdc-switch--disabled ) {
505
+ pointer-events : none ;
506
+ cursor : auto ;
507
+ }
508
+
509
+ & :has (.mat-mdc-slide-toggle-disabled-interactive ) {
510
+ pointer-events : auto ;
511
+ }
512
+
513
+ button , label {
514
+ cursor : inherit ;
515
+ }
516
+
517
+ // Increase the clickable area to cover the entire container.
518
+ label ::before {
519
+ content : ' ' ;
520
+ display : block ;
521
+ position : absolute ;
522
+ width : 100% ;
523
+ height : 100% ;
524
+ top : 0 ;
525
+ left : 0 ;
526
+ }
508
527
509
528
// Remove the native outline since we use the ripple for focus indication.
510
529
outline : 0 ;
@@ -564,11 +583,6 @@ $_interactive-disabled-selector: '.mat-mdc-slide-toggle-disabled-interactive.mdc
564
583
}
565
584
}
566
585
567
- // If our slide-toggle is enabled the cursor on label should appear as a pointer.
568
- .mdc-switch :enabled + .mdc-label {
569
- cursor : pointer ;
570
- }
571
-
572
586
// TODO(wagnermaciel): Use our custom token system to emit this css rule.
573
587
.mdc-switch--disabled + label {
574
588
color : var (--mdc-switch-disabled-label-text-color );
0 commit comments