Slider

Slider

A component that allows users to make selections from a range of values.


Installation

Slider uses the slider implementation from the composables library.

💡
Components with complex implementation are provided via the composables library.
dependencies {
    api("com.nomanr:composables:$version")
}

Then add the component:

./gradlew lumo --add Slider

Usage

Basic Slider

var value by remember { mutableFloatStateOf(0.5f) }
 
Slider(
    value = value,
    onValueChange = { value = it }
)

Range Slider

var range by remember { mutableStateOf(0.2f..0.8f) }
 
RangeSlider(
    value = range,
    onValueChange = { range = it },
    valueRange = 0f..100f,
    steps = 4,
    colors = SliderDefaults.colors(
        thumbColor = AppTheme.colors.primary,
        activeTrackColor = AppTheme.colors.primary
    )
)

API Documentation

Slider Parameters

ParameterTypeDescription
valueFloatCurrent value of the slider
onValueChange(Float) -> UnitCalled when value changes
modifierModifierModifier for the slider
enabledBooleanWhether the slider is enabled
valueRangeClosedRange<Float>Range of valid values
stepsIntNumber of discrete steps
colorsSliderColorsColors for different states
interactionSourceMutableInteractionSourceSource of interactions

RangeSlider Parameters

ParameterTypeDescription
valueClosedRange<Float>Current range values
onValueChange(ClosedRange<Float>) -> UnitCalled when range changes
modifierModifierModifier for the slider
enabledBooleanWhether the slider is enabled
valueRangeClosedRange<Float>Range of valid values
stepsIntNumber of discrete steps
colorsSliderColorsColors for different states
startInteractionSourceMutableInteractionSourceSource of start thumb interactions
endInteractionSourceMutableInteractionSourceSource of end thumb interactions