State of Compose 2023 results are in! Click here to learn more

← Back to Material Compose

RangeSlider

Component
in
Material
. Since 1.0.0

Overview

Code Examples

<a href="https://material.io/components/sliders" class="external" target="_blank">Material Design slider</a>.

Range Sliders expand upon Slider using the same concepts but allow the user to select 2 values.

The two values are still bounded by the value range but they also cannot cross each other.

Use continuous Range Sliders to allow users to make meaningful selections that don’t require a specific values:

Overloads

RangeSlider

@Composable
@ExperimentalMaterialApi
fun RangeSlider(
    value: ClosedFloatingPointRange<Float>,
    onValueChange: (ClosedFloatingPointRange<Float>) -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    valueRange: ClosedFloatingPointRange<Float> = 0f..1f,
    @IntRange(from = 0)
    steps: Int = 0,
    onValueChangeFinished: (() -> Unit)? = null,
    colors: SliderColors = SliderDefaults.colors()
)

Parameters

NameDescription
valuecurrent values of the RangeSlider. If either value is outside of valueRange provided, it will be coerced to this range.
onValueChangelambda in which values should be updated
modifiermodifiers for the Range Slider layout
enabledwhether or not component is enabled and can we interacted with or not
valueRangerange of values that Range Slider values can take. Passed value will be coerced to this range
stepsif greater than 0, specifies the amounts of discrete values, evenly distributed between across the whole value range. If 0, range slider will behave as a continuous slider and allow to choose any values from the range specified. Must not be negative.
onValueChangeFinishedlambda to be invoked when value change has ended. This callback shouldn't be used to update the range slider values (use onValueChange for that), but rather to know when the user has completed selecting a new value by ending a drag or a click.
colorsSliderColors that will be used to determine the color of the Range Slider parts in different state. See SliderDefaults.colors to customize