androidx.compose.material3

LinearProgressIndicator

Composable function

A progress indicator shows that something is happening. There are two kinds:

There are linear and circular versions, and wavy versions from Expressive. See Progress indicator types.

Linear: known progress and unknown
Linear: known progress and unknown
Column(Modifier.width(280.dp), verticalArrangement = Arrangement.spacedBy(24.dp)) {
    LinearProgressIndicator(progress = { 0.6f }, modifier = Modifier.width(280.dp))
    LinearProgressIndicator(modifier = Modifier.width(280.dp))
}
Circular: known progress and unknown
Circular: known progress and unknown
Row(horizontalArrangement = Arrangement.spacedBy(24.dp)) {
    CircularProgressIndicator(progress = { 0.6f })
    CircularProgressIndicator()
}
Wavy indicatorsExpressive theme
Wavy indicators
Row(horizontalArrangement = Arrangement.spacedBy(24.dp), verticalAlignment = Alignment.CenterVertically) {
    LinearWavyProgressIndicator(progress = { 0.6f }, modifier = Modifier.width(200.dp))
    CircularWavyProgressIndicator(progress = { 0.6f })
}

Known progress

Takes progress. Fills from 0 to 1.

@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) },
)

progress: () -> FloatRequired

A function that returns how far the task is, from 0 to 1. It is a function, so the indicator can read it often without recomposing the screen.

modifier: ModifierOptional

Default: Modifier

Changes size, padding, or position. Set the width of a linear indicator here.

color: ColorOptional

Default: ProgressIndicatorDefaults.linearColor

The color of the filled part. Default: the theme's primary.

Colors and a round end
Colors and a round end
LinearProgressIndicator(
    progress = { 0.4f },
    color = MaterialTheme.colorScheme.tertiary,
    trackColor = MaterialTheme.colorScheme.tertiaryContainer,
    strokeCap = StrokeCap.Round,
    modifier = Modifier.width(280.dp).height(8.dp),
)

trackColor: ColorOptional

Default: ProgressIndicatorDefaults.linearTrackColor

The color of the empty part.

strokeCap: StrokeCapOptional

Default: ProgressIndicatorDefaults.LinearStrokeCap

The shape of the line ends: round or square.

gapSize: DpOptional

Default: ProgressIndicatorDefaults.LinearIndicatorTrackGapSize

The gap between the filled part and the empty part.

drawStopIndicator: DrawScope.() -> UnitOptional

Default: { drawStopIndicator(drawScope = this, stopSize = ProgressIndicatorDefaults.LinearTrackStopIndicatorSize, color = color, strokeCap = strokeCap) }

Draws the small dot at the end of the track. Pass {} to hide it.

Unknown progress

No progress. Moves in a loop.

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

Same as above: modifier, color, trackColor, strokeCap, gapSize.

Progress indicator types