Skip to content

feat(material/slider): add customizable thumb dimensions for m2 and m3 #31439

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/material/slider/_m2-slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
slider-handle-height: 20px,
slider-handle-shape: 50%,
slider-handle-width: 20px,
slider-thumb-width: 48px,
slider-thumb-height: 48px,
slider-inactive-track-height: 4px,
slider-inactive-track-shape: 9999px,
slider-value-indicator-border-radius: 4px,
Expand Down
2 changes: 2 additions & 0 deletions src/material/slider/_m3-slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
slider-active-track-height: 4px,
slider-handle-height: 20px,
slider-handle-width: 20px,
slider-thumb-width: 48px,
slider-thumb-height: 48px,
slider-inactive-track-height: 4px,
slider-with-overlap-handle-outline-width: 1px,
slider-with-tick-marks-active-container-opacity: 0.38,
Expand Down
3 changes: 2 additions & 1 deletion src/material/slider/slider-thumb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ export class MatSliderVisualThumb implements _MatSliderVisualThumb, AfterViewIni
return;
}

this._ripple.radius = 24;
const thumbDiameter = this._hostElement.offsetHeight || 48;
this._ripple.radius = thumbDiameter / 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a token for this and default to computing this based on the slider thumb width/height (whichever is greater).

Copy link
Contributor Author

@mistrykaran91 mistrykaran91 Jul 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm bit new to css things, not sure I got it completely. As, in adding new token for this radius ? Also, do we need to update slider-input.ts too ? Line 778 where ripplePadding is 48px ?

this._sliderInput = sliderInput;
this._sliderInputEl = this._sliderInput._hostElement;

Expand Down
10 changes: 7 additions & 3 deletions src/material/slider/slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ $fallbacks: m3-slider.get-tokens();
left: -24px;
outline: none;
position: absolute;
height: 48px;
width: 48px;
height: token-utils.slot(slider-thumb-height, $fallbacks);
width: token-utils.slot(slider-thumb-width, $fallbacks);
pointer-events: none;

.mdc-slider--discrete & {
Expand Down Expand Up @@ -299,7 +299,7 @@ $fallbacks: m3-slider.get-tokens();
outline: none;
vertical-align: middle;
cursor: pointer;
height: 48px;
height: token-utils.slot(slider-thumb-height, $fallbacks);
margin: 0 $mat-slider-horizontal-margin;
position: relative;
touch-action: pan-y;
Expand All @@ -319,6 +319,10 @@ $fallbacks: m3-slider.get-tokens();
}
}

&[hidden] {
height: token-utils.slot(slider-thumb-height, $fallbacks);
}

.mdc-slider__thumb,
.mdc-slider__track--active_fill {
transition-duration: 0ms;
Expand Down
Loading