LinearProgressIndicator

Functions summary

Unit
@Composable
LinearProgressIndicator(
    modifier: Modifier,
    color: Color,
    trackColor: Color,
    strokeCap: StrokeCap,
    gapSize: Dp
)

Material Design indeterminate linear progress indicator

Cmn
Unit
@Composable
LinearProgressIndicator(
    progress: Float,
    modifier: Modifier,
    color: Color,
    trackColor: Color,
    strokeCap: StrokeCap
)

This function is deprecated. Use the overload that takes `progress` as a lambda

Cmn
Unit
@Composable
LinearProgressIndicator(
    progress: () -> Float,
    modifier: Modifier,
    color: Color,
    trackColor: Color,
    strokeCap: StrokeCap,
    gapSize: Dp,
    drawStopIndicator: DrawScope.() -> Unit
)

Material Design determinate linear progress indicator

Cmn

Functions

LinearProgressIndicator

@Composable
fun LinearProgressIndicator(
    modifier: Modifier = Modifier,
    color: Color = ProgressIndicatorDefaults.linearColor,
    trackColor: Color = ProgressIndicatorDefaults.linearTrackColor,
    strokeCap: StrokeCap = ProgressIndicatorDefaults.LinearStrokeCap,
    gapSize: Dp = ProgressIndicatorDefaults.LinearIndicatorTrackGapSize
): Unit

Material Design indeterminate linear progress indicator

Progress indicators express an unspecified wait time or display the duration of a process.

Linear progress indicator
image

import androidx.compose.foundation.layout.Column
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.ui.Alignment

Column(horizontalAlignment = Alignment.CenterHorizontally) { LinearProgressIndicator() }
Parameters
modifier: Modifier = Modifier

the Modifier to be applied to this progress indicator

color: Color = ProgressIndicatorDefaults.linearColor

color of this progress indicator

trackColor: Color = ProgressIndicatorDefaults.linearTrackColor

color of the track behind the indicator, visible when the progress has not reached the area of the overall indicator yet

strokeCap: StrokeCap = ProgressIndicatorDefaults.LinearStrokeCap

stroke cap to use for the ends of this progress indicator

gapSize: Dp = ProgressIndicatorDefaults.LinearIndicatorTrackGapSize

size of the gap between the progress indicator and the track

LinearProgressIndicator

@Composable
fun LinearProgressIndicator(
    progress: Float,
    modifier: Modifier = Modifier,
    color: Color = ProgressIndicatorDefaults.linearColor,
    trackColor: Color = ProgressIndicatorDefaults.linearTrackColor,
    strokeCap: StrokeCap = ProgressIndicatorDefaults.LinearStrokeCap
): Unit

LinearProgressIndicator

@Composable
fun LinearProgressIndicator(
    progress: () -> Float,
    modifier: Modifier = Modifier,
    color: Color = ProgressIndicatorDefaults.linearColor,
    trackColor: Color = ProgressIndicatorDefaults.linearTrackColor,
    strokeCap: StrokeCap = ProgressIndicatorDefaults.LinearStrokeCap,
    gapSize: Dp = ProgressIndicatorDefaults.LinearIndicatorTrackGapSize,
    drawStopIndicator: DrawScope.() -> Unit = { drawStopIndicator( drawScope = this, stopSize = ProgressIndicatorDefaults.LinearTrackStopIndicatorSize, color = color, strokeCap = strokeCap, ) }
): Unit

Material Design determinate linear progress indicator

Progress indicators express an unspecified wait time or display the duration of a process.

Linear progress indicator
image

By default there is no animation between progress values. You can use ProgressIndicatorDefaults.ProgressAnimationSpec as the default recommended androidx.compose.animation.core.AnimationSpec when animating progress, such as in the following example:

import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.width
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.ProgressIndicatorDefaults
import androidx.compose.material3.Slider
import androidx.compose.material3.Text
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

var progress by remember { mutableFloatStateOf(0.1f) }
val animatedProgress by
    animateFloatAsState(
        targetValue = progress,
        animationSpec = ProgressIndicatorDefaults.ProgressAnimationSpec,
    )

Column(horizontalAlignment = Alignment.CenterHorizontally) {
    LinearProgressIndicator(progress = { animatedProgress })
    Spacer(Modifier.requiredHeight(30.dp))
    Text("Set progress:")
    Slider(
        modifier = Modifier.width(300.dp),
        value = progress,
        valueRange = 0f..1f,
        onValueChange = { progress = it },
    )
}
Parameters
progress: () -> Float

the progress of this progress indicator, where 0.0 represents no progress and 1.0 represents full progress. Values outside of this range are coerced into the range.

modifier: Modifier = Modifier

the Modifier to be applied to this progress indicator

color: Color = ProgressIndicatorDefaults.linearColor

color of this progress indicator

trackColor: Color = ProgressIndicatorDefaults.linearTrackColor

color of the track behind the indicator, visible when the progress has not reached the area of the overall indicator yet

strokeCap: StrokeCap = ProgressIndicatorDefaults.LinearStrokeCap

stroke cap to use for the ends of this progress indicator

gapSize: Dp = ProgressIndicatorDefaults.LinearIndicatorTrackGapSize

size of the gap between the progress indicator and the track

drawStopIndicator: DrawScope.() -> Unit = { drawStopIndicator( drawScope = this, stopSize = ProgressIndicatorDefaults.LinearTrackStopIndicatorSize, color = color, strokeCap = strokeCap, ) }

lambda that will be called to draw the stop indicator. Note that a custom indicator implementation should also handle RTL layouts.