StylishSlider

fun StylishSlider(value: Float, onValueChange: (Float) -> Unit, modifier: Modifier = Modifier, enabled: Boolean = true, valueRange: ClosedFloatingPointRange<Float> = 0f..1f, steps: Int = 0, onValueChangeFinished: () -> Unit? = null, colors: SliderColors = SliderDefaults.colors( thumbColor = MaterialTheme.colorScheme.primary, activeTrackColor = MaterialTheme.colorScheme.primary, inactiveTrackColor = MaterialTheme.colorScheme.surfaceVariant, ), interactionSource: MutableInteractionSource? = null)

A slider for selecting a single value from a continuous or stepped range, wrapping the Material 3 Slider with Stylish defaults.

Use a slider when the exact value is secondary to the position along a range (volume, brightness, price). For selecting both endpoints of a range use StylishRangeSlider, and for a stepped on/off choice prefer StylishSwitch or StylishCheckbox.

Parameters

value

Current value of the slider. Coerced to valueRange if outside of it.

onValueChange

Called with the new value while the user drags or taps the track.

modifier

Modifier applied to the Slider root. The root carries the default test tag stylish_slider for UI tests; callers can override it by passing their own Modifier.testTag(...) here.

enabled

When false, the slider ignores pointer input and renders in the disabled color scheme.

valueRange

Range of values the slider can take. Defaults to 0f..1f.

steps

If positive, the number of discrete steps between the endpoints of valueRange. For example, 0f..10f with 4 steps allows 2, 4, 6, and 8. 0 makes the slider continuous.

onValueChangeFinished

Called when the user completes a drag or tap. Use this for expensive operations; update the value in onValueChange.

colors

SliderColors for each state. Defaults to a primary thumb and active track with a MaterialTheme.colorScheme.surfaceVariant inactive track.

interactionSource

Optional hoisted MutableInteractionSource for observing interactions with the slider. When null, an internal instance is remembered.

See also