LinearWavyProgressIndicator

Functions summary

Unit
@ExperimentalMaterial3ExpressiveApi
@Composable
LinearWavyProgressIndicator(
    modifier: Modifier,
    color: Color,
    trackColor: Color,
    stroke: Stroke,
    trackStroke: Stroke,
    gapSize: Dp,
    amplitude: @FloatRange(from = 0.0, to = 1.0) Float,
    wavelength: Dp,
    waveSpeed: Dp
)

Material Design indeterminate linear wavy progress indicator

Cmn
Unit
@ExperimentalMaterial3ExpressiveApi
@Composable
LinearWavyProgressIndicator(
    progress: () -> Float,
    modifier: Modifier,
    color: Color,
    trackColor: Color,
    stroke: Stroke,
    trackStroke: Stroke,
    gapSize: Dp,
    stopSize: Dp,
    amplitude: (progress: Float) -> Float,
    wavelength: Dp,
    waveSpeed: Dp
)

Material Design determinate wavy linear progress indicator

Cmn

Functions

LinearWavyProgressIndicator

@ExperimentalMaterial3ExpressiveApi
@Composable
fun LinearWavyProgressIndicator(
    modifier: Modifier = Modifier,
    color: Color = WavyProgressIndicatorDefaults.indicatorColor,
    trackColor: Color = WavyProgressIndicatorDefaults.trackColor,
    stroke: Stroke = WavyProgressIndicatorDefaults.linearIndicatorStroke,
    trackStroke: Stroke = WavyProgressIndicatorDefaults.linearTrackStroke,
    gapSize: Dp = WavyProgressIndicatorDefaults.LinearIndicatorTrackGapSize,
    amplitude: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f,
    wavelength: Dp = WavyProgressIndicatorDefaults.LinearIndeterminateWavelength,
    waveSpeed: Dp = wavelength
): Unit

Material Design indeterminate linear wavy progress indicator

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

Indeterminate linear wavy progress indicator
image

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

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

the Modifier to be applied to this progress indicator

color: Color = WavyProgressIndicatorDefaults.indicatorColor

the progress indicator color

trackColor: Color = WavyProgressIndicatorDefaults.trackColor

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

stroke: Stroke = WavyProgressIndicatorDefaults.linearIndicatorStroke

a Stroke that will be used to draw this indicator

trackStroke: Stroke = WavyProgressIndicatorDefaults.linearTrackStroke

a Stroke that will be used to draw the indicator's track

gapSize: Dp = WavyProgressIndicatorDefaults.LinearIndicatorTrackGapSize

the gap between the track and the progress parts of the indicator

amplitude: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f

the wave's amplitude. 0.0 represents no amplitude, and 1.0 represents an amplitude that will take the full height of the progress indicator. Values outside of this range are coerced into the range.

wavelength: Dp = WavyProgressIndicatorDefaults.LinearIndeterminateWavelength

the length of a wave

waveSpeed: Dp = wavelength

the speed in which the wave will move when the amplitude is greater than zero. The value here represents a DP per seconds, and by default it's matched to the wavelength to render an animation that moves the wave by one wave length per second.

LinearWavyProgressIndicator

@ExperimentalMaterial3ExpressiveApi
@Composable
fun LinearWavyProgressIndicator(
    progress: () -> Float,
    modifier: Modifier = Modifier,
    color: Color = WavyProgressIndicatorDefaults.indicatorColor,
    trackColor: Color = WavyProgressIndicatorDefaults.trackColor,
    stroke: Stroke = WavyProgressIndicatorDefaults.linearIndicatorStroke,
    trackStroke: Stroke = WavyProgressIndicatorDefaults.linearTrackStroke,
    gapSize: Dp = WavyProgressIndicatorDefaults.LinearIndicatorTrackGapSize,
    stopSize: Dp = WavyProgressIndicatorDefaults.LinearTrackStopIndicatorSize,
    amplitude: (progress: Float) -> Float = WavyProgressIndicatorDefaults.indicatorAmplitude,
    wavelength: Dp = WavyProgressIndicatorDefaults.LinearDeterminateWavelength,
    waveSpeed: Dp = wavelength
): Unit

Material Design determinate wavy linear progress indicator

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

Linear wavy progress indicator
image

This version of a linear progress indicator accepts arguments, such as amplitude, wavelength, and waveSpeed to render the progress as a waveform.

By default there is no animation between progress values. You can use WavyProgressIndicatorDefaults.ProgressAnimationSpec as the default recommended 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.LinearWavyProgressIndicator
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) {
    LinearWavyProgressIndicator(progress = { animatedProgress })
    Spacer(Modifier.requiredHeight(30.dp))
    Text("Set progress:")
    Slider(
        modifier = Modifier.width(300.dp),
        value = progress,
        valueRange = 0f..1f,
        onValueChange = { progress = it },
    )
}

You may also follow the Material guidelines to create a thicker version of this indicator, like in this example:

import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.width
import androidx.compose.material3.LinearWavyProgressIndicator
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.graphics.StrokeCap
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp

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

val thickStrokeWidth = with(LocalDensity.current) { 8.dp.toPx() }
val thickStroke =
    remember(thickStrokeWidth) { Stroke(width = thickStrokeWidth, cap = StrokeCap.Round) }

Column(horizontalAlignment = Alignment.CenterHorizontally) {
    LinearWavyProgressIndicator(
        progress = { animatedProgress },
        // Thick height is slightly higher than the
        // WavyProgressIndicatorDefaults.LinearContainerHeight default
        modifier = Modifier.height(14.dp),
        stroke = thickStroke,
        trackStroke = thickStroke,
    )
    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 = WavyProgressIndicatorDefaults.indicatorColor

the progress indicator color

trackColor: Color = WavyProgressIndicatorDefaults.trackColor

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

stroke: Stroke = WavyProgressIndicatorDefaults.linearIndicatorStroke

a Stroke that will be used to draw this indicator

trackStroke: Stroke = WavyProgressIndicatorDefaults.linearTrackStroke

a Stroke that will be used to draw the indicator's track

gapSize: Dp = WavyProgressIndicatorDefaults.LinearIndicatorTrackGapSize

the gap between the track and the progress parts of the indicator

stopSize: Dp = WavyProgressIndicatorDefaults.LinearTrackStopIndicatorSize

the size of the stop indicator at the end of the track. Note that the stop indicator is required if the track has a contrast below 3:1 with its container or the surface behind the container.

amplitude: (progress: Float) -> Float = WavyProgressIndicatorDefaults.indicatorAmplitude

a lambda that provides an amplitude for the wave path as a function of the indicator's progress. 0.0 represents no amplitude, and 1.0 represents an amplitude that will take the full height of the progress indicator. Values outside of this range are coerced into the range.

wavelength: Dp = WavyProgressIndicatorDefaults.LinearDeterminateWavelength

the length of a wave. Will be applied in case the path has an amplitude that is greater than zero and represents a wave.

waveSpeed: Dp = wavelength

the speed in which the wave will move when the amplitude is greater than zero. The value here represents a DP per seconds, and by default it's matched to the wavelength to render an animation that moves the wave by one wave length per second.