Stepper

Composable Component

Stepper allows users to make a selection from a range of values. It's a full-screen control with increase button on the top, decrease button on the bottom and a slot (expected to have either Text or Button) in the middle. Value can be increased and decreased by clicking on the increase and decrease buttons. Buttons can have custom icons - decreaseIcon and increaseIcon. Step value is calculated as the difference between min and max values divided by steps+1. Stepper itself doesn't show the current value but can be displayed via the content slot or StepperLevelIndicator if required. If value is not equal to any step value, then it will be coerced to the closest step value. However, the value itself will not be changed and onValueChange in this case will not be triggered. To add range semantics on Stepper, use Modifier.rangeSemantics.

Android
@Composable
public fun Stepper(
    value: Float,
    onValueChange: (Float) -> Unit,
    steps: Int,
    decreaseIcon: @Composable () -> Unit,
    increaseIcon: @Composable () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    valueRange: ClosedFloatingPointRange<Float> = 0f..(steps + 1).toFloat(),
    colors: StepperColors = StepperDefaults.colors(),
    content: @Composable BoxScope.() -> Unit,
)

Parameters

valueCurrent value of the Stepper. If outside of valueRange provided, value will be coerced to this range.
onValueChangeLambda in which value should be updated.
stepsSpecifies the number of discrete values, excluding min and max values, evenly distributed across the whole value range. Must not be negative. If 0, stepper will have only min and max values and no steps in between.
modifierModifiers for the Stepper layout.
decreaseIconA slot for an icon which is placed on the decrease (bottom) button.
increaseIconA slot for an icon which is placed on the increase (top) button.
enabledWhether the Stepper is enabled.
valueRangeRange of values that Stepper value can take. Passed value will be coerced to this range.
colorsStepperColors that will be used to resolve the colors used for this Stepper. See StepperDefaults.colors.
contentContent body for the Stepper.
Android
@Composable
public fun Stepper(
    value: Int,
    onValueChange: (Int) -> Unit,
    valueProgression: IntProgression,
    decreaseIcon: @Composable () -> Unit,
    increaseIcon: @Composable () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    colors: StepperColors = StepperDefaults.colors(),
    content: @Composable BoxScope.() -> Unit,
)

Parameters

valueCurrent value of the Stepper. If outside of valueProgression provided, value will be coerced to this range.
onValueChangeLambda in which value should be updated.
valueProgressionProgression of values that Stepper value can take. Consists of rangeStart, rangeEnd and step. Range will be equally divided by step size.
modifierModifiers for the Stepper layout.
decreaseIconA slot for an icon which is placed on the decrease (bottom) button.
increaseIconA slot for an icon which is placed on the increase (top) button.
enabledWhether the Stepper is enabled.
colorsStepperColors that will be used to resolve the colors used for this Stepper. See StepperDefaults.colors.
contentContent body for the Stepper.