components icon indicating copy to clipboard operation
components copied to clipboard

mat-slider: disable special styling on minimum value

Open dmarku opened this issue 5 years ago • 7 comments

Feature Description

If a <mat-slider> is set to its minimum value, it adds a special class (.mat-slider-min-value) that changes the styling of the slider thumb. It would be useful to disable this behavior or adjust the value where this "resting state" occurs.

Use Case

In our scenario, the slider ranges from negative to positive values, so the minimum value is not semantically different to other values (except maybe the zero position). It would be nice to visually represent this equality.

dmarku avatar Jan 27 '20 15:01 dmarku

This will be fixed in the MDC-based implementation of the slider we are working on. At first glance, it looks like the Material Design specification no longer has special styles for the minimum value.

devversion avatar May 26 '20 12:05 devversion

Would you consider leaving the existing styling in place and instead separating out the "min" and "default" values? So, <mat-slider min="-10" max="10" default="0"> would show the same special styling as the .mat-slider-min-value class currently provides, but only when the slider is positioned at the value zero -- i.e., the exact middle of the range. That would also neatly solve the case that led me to find this issue: I want a slider that runs from 20-100, with a falsy "default" so that it never uses the min-value styling.

thw0rted avatar Dec 07 '20 15:12 thw0rted

Hello, Any updates or other suggestions to solve this?

hannounf avatar Sep 16 '21 19:09 hannounf

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

angular-robot[bot] avatar Feb 22 '22 15:02 angular-robot[bot]

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

angular-robot[bot] avatar Mar 14 '22 15:03 angular-robot[bot]

There is no reason to have a separate styling for the minimum value except for a specific use cases where the minimum value means empty and/or is an invalid selection.

sdalexandre avatar Jun 28 '22 18:06 sdalexandre

Why is there this special behavior? As @sdalexandre stated, the only meaningful usage for this feature is that the minimum value has a speacial meaning like empty or invalid. But when i use a slider, my normal usecase is to give the user the possibility to select a value from a range of values, where the minimum is equal in value to all the other values up to the maximum. The case that angular states as the normal case is in my opinion the special case that should be enabled with an attribute or at least be possible to disable with an attribute.

zreptil avatar Sep 10 '22 16:09 zreptil

With a bigger thumb-label, the min-value class is useful to set the label placement. But sadly, there is no equivalent for "max-value". This inconsistency is annoying. Please, add max-value, or replace min-value by default value, or remove min-value to be consistent. I would remove it as we can add a custom class easily on min-max value.

ger-benjamin avatar Nov 08 '22 12:11 ger-benjamin

exactly, why we can't set special style / color on min / max value? specially for min

Mateusz19021996 avatar Dec 08 '22 22:12 Mateusz19021996

Hi folks! The new MDC slider came out in v15 and I believe this is no longer relevant since there's no special styling on the minimum value anymore

For additional context, this is not something we plan to bring back because 1. it diverges from the latest Material design spec and 2. this seems really trivial to add back in if you really want it

E.g.

<mat-slider
    [color]="mySliderThumb.value === mySlider.min || mySliderThumb.value === mySlider.max ? 'warn' : 'primary'"
    #mySlider>
        <input #mySliderThumb="matSliderThumb" matSliderThumb>
</mat-slider>

wagnermaciel avatar Dec 08 '22 23:12 wagnermaciel

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.