stepperSemantics

fun Modifier.stepperSemantics(value: Int, onValueChange: (Int) -> Unit, range: IntRange, step: Int, suffix: String?, enabled: Boolean): Modifier

Adds semantics to a Stepper component, enabling accessibility features from TalkBack.

This modifier configures the component to behave like a slider, allowing users to adjust the value within the specified range using accessibility features from TalkBack.

Parameters

value

The current value of the stepper.

onValueChange

When the value has been incremented or decremented.

range

The same range used with the Stepper or StepperForm.

enabled

Whether the stepper is enabled or disabled. Disabled steppers cannot be interacted with and will be announced as disabled

Usage Example:

var stepperValue by remember { mutableStateOf(50) }

Row(
Modifier
.fillMaxWidth()
.semantics { text = label }
.stepperSemantics(
value = stepperValue,
onValueChange = { stepperValue = it },
range = 0..100,
enabled = true
)
) {
Text(
text = label,
modifier = Modifier.invisibleSemantic()
)
Stepper(
...
allowSemantics = false // Important otherwise the semantics will be duplicated
...
)
}