ion.rangeSlider icon indicating copy to clipboard operation
ion.rangeSlider copied to clipboard

Use custom color range

Open danieldestro opened this issue 4 years ago • 5 comments

I want to use a custom color range that optionally may change the color of the current slider tag according to its position. Is it possible?

image

danieldestro avatar Apr 16 '21 19:04 danieldestro

Hi, use this technique to update the sliders skin to match your needs: https://developer.mozilla.org/en-US/docs/Web/CSS/linear-gradient()#gradient_with_multi-position_color_stops

IonDen avatar Apr 18 '21 17:04 IonDen

Thanks @IonDen but it did not work as expected. I tried to replace "background" attribute for either the following classes (.irs-line, .irs-bar, .irs). What I want is to show the colors in the bar as it is displayed in my mockup above.

danieldestro avatar Apr 19 '21 15:04 danieldestro

Please prepare the demo, I can't say what is not working without seeing your code. https://jsfiddle.net/IonDen/uqs7njp9/

IonDen avatar Apr 19 '21 15:04 IonDen

I figured it out. Thanks for the fiddle.

This works as I wish:

.irs--round .irs-bar { background: transparent; }
.irs--round .irs-line { background: linear-gradient(90deg, yellow, green); }

I was doing this, that´s why the colors changed as the handle moves:

.irs--round .irs-bar { background: linear-gradient(90deg, red, green); }

Fiddle updated: https://jsfiddle.net/danieldestro/utpy3g8x/

danieldestro avatar Apr 19 '21 18:04 danieldestro

Great, good luck!

IonDen avatar Apr 20 '21 07:04 IonDen