Slider

fun Slider(value: Float, startLabel: String, endLabel: String, onValueChange: (Float) -> Unit, modifier: Modifier = Modifier, label: String = "", interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, onValueChangeFinished: () -> Unit = {}, sliderRange: ClosedFloatingPointRange<Float> = 0f..1f, @IntRange(from = 0) steps: Int = 0, stateDescription: (Float) -> String = { (round(it * 10) / 10).toString() })

Slider - Default

Sliders provide a visual indication of adjustable content, where the user can increase or decrease the value by moving the handle along a horizontal track.

Disclaimer: Due to layout complexities - and lack of guidance from Carbon documentation - for narrow widths like mobile targets, text inputs could not be directly integrated into the Slider component. You may wrap the Slider with text input components yourself if this functionality is desired.

(From Slider documentation)

Parameters

value

The current value of the slider.

startLabel

The label displayed at the start of the slider.

endLabel

The label displayed at the end of the slider.

onValueChange

Callback invoked when the slider value changes.

modifier

The modifier to be applied to the slider.

label

A label to be displayed above the slider.

interactionSource

The MutableInteractionSource representing the stream of androidx.compose.foundation.interaction.Interactions for this slider. You can create and pass in your own remembered instance to observe androidx.compose.foundation.interaction.Interactions and customize the appearance and behavior of this slider in different states.

onValueChangeFinished

Callback invoked when the user has finished interacting with the slider.

sliderRange

The range of values that the slider can take.

steps

The step value of the slider.

stateDescription

A lambda that returns the state description of the slider for accessibility services based on the current value.