New Compose Multiplatform components arrived on Composables UICheck it out →

Modifier in Compose Foundation

progressSemantics

Common

Contains the [semantics] required for a determinate progress indicator or the progress part of a slider, that represents progress within [valueRange]. [value] outside of this range will be coerced into this range.

Last updated:

Installation

dependencies {
   implementation("androidx.compose.foundation:foundation:1.7.0-beta04")
}

Overloads

@Stable
fun Modifier.progressSemantics(
    value: Float,
    valueRange: ClosedFloatingPointRange<Float> = 0f..1f,
    @IntRange(from = 0)
    steps: Int = 0
)

Parameters

namedescription
valuecurrent value of the ProgressIndicator/Slider. If outside of [valueRange] provided, value will be coerced to this range. Must not be NaN.
valueRangerange of values that value 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, any value from the range specified is allowed. Must not be negative.
@Stable
fun Modifier.progressSemantics()

Code Examples

DeterminateProgressSemanticsSample

@Composable
@Sampled
fun DeterminateProgressSemanticsSample() {
    val progress = 0.5f // emulate progress from some state
    Box(
        Modifier
            .progressSemantics(progress)
            .size((progress * 100).dp, 4.dp)
            .background(color = Color.Cyan)
    )
}

IndeterminateProgressSemanticsSample

@Composable
@Sampled
fun IndeterminateProgressSemanticsSample() {
    Box(Modifier.progressSemantics().background(color = Color.Cyan)) {
        Text("Operation is on progress")
    }
}