Skip to content

Commit 9019a0e

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

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

src/material/slider/_m2-slider.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
slider-handle-height: 20px,
1515
slider-handle-shape: 50%,
1616
slider-handle-width: 20px,
17+
slider-thumb-width: 48px,
18+
slider-thumb-height: 48px,
1719
slider-inactive-track-height: 4px,
1820
slider-inactive-track-shape: 9999px,
1921
slider-value-indicator-border-radius: 4px,

src/material/slider/_m3-slider.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
slider-active-track-height: 4px,
2525
slider-handle-height: 20px,
2626
slider-handle-width: 20px,
27+
slider-thumb-width: 48px,
28+
slider-thumb-height: 48px,
2729
slider-inactive-track-height: 4px,
2830
slider-with-overlap-handle-outline-width: 1px,
2931
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: 7 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-height, $fallbacks);
179+
width: token-utils.slot(slider-thumb-width, $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-height, $fallbacks);
303303
margin: 0 $mat-slider-horizontal-margin;
304304
position: relative;
305305
touch-action: pan-y;
@@ -319,6 +319,10 @@ $fallbacks: m3-slider.get-tokens();
319319
}
320320
}
321321

322+
&[hidden] {
323+
height: token-utils.slot(slider-thumb-height, $fallbacks);
324+
}
325+
322326
.mdc-slider__thumb,
323327
.mdc-slider__track--active_fill {
324328
transition-duration: 0ms;

0 commit comments

Comments
 (0)