Change Circle shape of Thumb in Slider Jetpack compose

Viewed 646

The Slider in Jetpack Compose allows changing the color of the thumb but not the shape. I'm looking solution to change the shape of the thumb from circle to rectangle as represented in the attached image

enter image description here

I tried to add Slider.kt file to the project as mentioned here but, strangely, when I copy this code to the project I got a lot of errors, see attached screenshot

enter image description here

1 Answers

Here is a source code for Slider composable.

You can copy it to your project, rename, and change the Thumb shape in the SliderThumb composable:

...
.shadow(if (enabled) elevation else 0.dp, CircleShape, clip = false)
.background(colors.thumbColor(enabled).value, CircleShape)
...
Related