LinearProgressIndicator

Material Design linear progress indicator.

Android
@Composable
public fun LinearProgressIndicator(
    progress: () -> Float,
    modifier: Modifier = Modifier,
    colors: ProgressIndicatorColors = ProgressIndicatorDefaults.colors(),
    strokeWidth: Dp = LinearProgressIndicatorDefaults.StrokeWidthLarge,
    enabled: Boolean = true,
)

Parameters

progress The progress of this progress indicator where 0.0 represents no progress and 1.0 represents completion. Values outside of this range are coerced into the range 0..1. Progress value changes will be animated.
modifier Modifier to be applied to the LinearProgressIndicator.
colors ProgressIndicatorColors that will be used to resolve the indicator and track colors for this progress indicator in different states.
strokeWidth The stroke width for the progress indicator. The minimum value is LinearProgressIndicatorDefaults.StrokeWidthSmall to ensure that the dot drawn at the end of the range can be distinguished.
enabled controls the enabled state. Although this component is not clickable, it can be contained within a clickable component. When enabled is false, this component will appear visually disabled.

Code Examples

LinearProgressIndicatorSample

@Composable
fun LinearProgressIndicatorSample(progress: () -> Float, enabled: Boolean = true) {
    Box(
        modifier = Modifier.background(MaterialTheme.colorScheme.background).fillMaxSize(),
        contentAlignment = Alignment.Center,
    ) {
        LinearProgressIndicator(
            progress = progress,
            enabled = enabled,
            modifier =
                Modifier.semantics(mergeDescendants = true) {
                    progressBarRangeInfo = ProgressBarRangeInfo(progress(), 0f..1f)
                },
        )
    }
}