Skip to content

Commit f8cab36

Browse files
committed
feat(material/slider): add customizable thumb dimensions for m2 and m3
Fixes #31101
1 parent 3db4f23 commit f8cab36

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

src/material/slider/_m2-slider.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
slider-handle-height: 20px,
1515
slider-handle-shape: 50%,
1616
slider-handle-width: 20px,
17+
slider-thumb-diameter: 48px,
1718
slider-inactive-track-height: 4px,
1819
slider-inactive-track-shape: 9999px,
1920
slider-value-indicator-border-radius: 4px,

src/material/slider/_m3-slider.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
slider-active-track-height: 4px,
2525
slider-handle-height: 20px,
2626
slider-handle-width: 20px,
27+
slider-thumb-diameter: 48px,
2728
slider-inactive-track-height: 4px,
2829
slider-with-overlap-handle-outline-width: 1px,
2930
slider-with-tick-marks-active-container-opacity: 0.38,

src/material/slider/slider-thumb.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ export class MatSliderVisualThumb implements _MatSliderVisualThumb, AfterViewIni
117117
return;
118118
}
119119

120-
this._ripple.radius = 24;
120+
const thumbDiameter = this._hostElement.offsetHeight || 48;
121+
this._ripple.radius = thumbDiameter / 2;
121122
this._sliderInput = sliderInput;
122123
this._sliderInputEl = this._sliderInput._hostElement;
123124

src/material/slider/slider.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ $fallbacks: m3-slider.get-tokens();
175175
left: -24px;
176176
outline: none;
177177
position: absolute;
178-
height: 48px;
179-
width: 48px;
178+
height: token-utils.slot(slider-thumb-diameter, $fallbacks);
179+
width: token-utils.slot(slider-thumb-diameter, $fallbacks);
180180
pointer-events: none;
181181

182182
.mdc-slider--discrete & {
@@ -299,7 +299,7 @@ $fallbacks: m3-slider.get-tokens();
299299
outline: none;
300300
vertical-align: middle;
301301
cursor: pointer;
302-
height: 48px;
302+
height: token-utils.slot(slider-thumb-diameter, $fallbacks);
303303
margin: 0 $mat-slider-horizontal-margin;
304304
position: relative;
305305
touch-action: pan-y;

0 commit comments

Comments
 (0)