Search
MaterialComponentsDocs
Components overviewApp barBadgeButtonsButton groupButtonExtended FABFAB menuFABIcon buttonSplit buttonCardCarouselCheckboxChipsDate & time pickersDate pickerTime pickerDialogDividerListLoading & progressLoading indicatorProgressMenuNavigationNavigation barNavigation drawerNavigation railRadio buttonsSearchSelectSheetsBottom sheetSide sheetSliderSnackbarSwitchTabsText fieldToolbarTooltip

Progress

Show how a task is progressing. Compare linear and circular indicators, with flat or wavy shapes.

FactoryWeb ComponentsReactVueSvelteSolidJS
PublishedUpdated

A progress indicator shows how far a process has come, such as an upload, or that one is running when its length is unknown. It is linear or circular, determinate or indeterminate, and its active indicator is flat or wavy.

Usage

ariaLabel says what is in progress.

Vanilla
import { createProgress } from 'material';

const progress = createProgress({ value: 40, ariaLabel: 'Uploading photo' });
document.body.append(progress.element);
Web Components
<m-progress value="40" aria-label="Uploading photo"></m-progress>
React
import { Progress } from 'material/react';

export function Example() {
  return (
    <Progress value={40} ariaLabel="Uploading photo" />
  );
}
Vue
<script setup lang="ts">
import { MProgress } from 'material/vue';
</script>

<template>
  <MProgress :value="40" aria-label="Uploading photo" />
</template>
Svelte
<script lang="ts">
  import { Progress } from 'material/svelte';
</script>

<Progress value={40} ariaLabel="Uploading photo" />
SolidJS
import { Progress } from 'material/solid';

export function Example() {
  return (
    <Progress value={40} ariaLabel="Uploading photo" />
  );
}

Examples

Circular, indeterminate

indeterminate shows activity without a value. A circular indicator is 40px across, 48px when wavy; size sets it, from 24 to 240.

Vanilla
import { createProgress } from 'material';

const progress = createProgress({
  variant: 'circular',
  indeterminate: true,
  ariaLabel: 'Loading messages',
});
document.body.append(progress.element);
Web Components
<m-progress variant="circular" indeterminate aria-label="Loading messages"></m-progress>
React
import { Progress } from 'material/react';

export function Example() {
  return (
    <Progress variant="circular" indeterminate ariaLabel="Loading messages" />
  );
}
Vue
<script setup lang="ts">
import { MProgress } from 'material/vue';
</script>

<template>
  <MProgress variant="circular" indeterminate aria-label="Loading messages" />
</template>
Svelte
<script lang="ts">
  import { Progress } from 'material/svelte';
</script>

<Progress variant="circular" indeterminate ariaLabel="Loading messages" />
SolidJS
import { Progress } from 'material/solid';

export function Example() {
  return (
    <Progress variant="circular" indeterminate ariaLabel="Loading messages" />
  );
}

Wavy and thick

shape: 'wavy' draws the active indicator as a wave, which flattens near the start and the end. thickness is thin (4px), thick (8px) or a number of pixels.

Vanilla
import { createProgress } from 'material';

const progress = createProgress({
  shape: 'wavy',
  thickness: 'thick',
  value: 60,
  ariaLabel: 'Installing update',
});
document.body.append(progress.element);
Web Components
<m-progress value="60" shape="wavy" thickness="thick" aria-label="Installing update"></m-progress>
React
import { Progress } from 'material/react';

export function Example() {
  return (
    <Progress value={60} shape="wavy" thickness="thick" ariaLabel="Installing update" />
  );
}
Vue
<script setup lang="ts">
import { MProgress } from 'material/vue';
</script>

<template>
  <MProgress :value="60" shape="wavy" thickness="thick" aria-label="Installing update" />
</template>
Svelte
<script lang="ts">
  import { Progress } from 'material/svelte';
</script>

<Progress value={60} shape="wavy" thickness="thick" ariaLabel="Installing update" />
SolidJS
import { Progress } from 'material/solid';

export function Example() {
  return (
    <Progress value={60} shape="wavy" thickness="thick" ariaLabel="Installing update" />
  );
}

Setting the value

An action sets the value, which animates to it over 500ms; setValue(value, false) jumps. A value out of range is clamped to 0 or max, and that is the value drawn, announced, labelled and emitted.

Vanilla
import { createProgress } from 'material';

const progress = createProgress({ value: 30, buffer: 60, ariaLabel: 'Streaming video' });
document.body.append(progress.element);

function advance() {
  progress.setValue(75);
}
Web Components
<m-progress value="30" buffer="60" aria-label="Streaming video"></m-progress>

<script type="module">
  const progress = document.querySelector('m-progress');

  function advance() {
    progress.value = 75;
  }
</script>
React
import { useState } from 'react';
import { Progress } from 'material/react';

export function Example() {
  const [value, setValue] = useState(30);
  const advance = () => setValue(75);

  return (
    <Progress value={value} buffer={60} ariaLabel="Streaming video" />
  );
}
Vue
<script setup lang="ts">
import { ref } from 'vue';
import { MProgress } from 'material/vue';

const value = ref(30);

function advance() {
  value.value = 75;
}
</script>

<template>
  <MProgress :value="value" :buffer="60" aria-label="Streaming video" />
</template>
Svelte
<script lang="ts">
  import { Progress } from 'material/svelte';

  let value = $state(30);

  function advance() {
    value = 75;
  }
</script>

<Progress value={value} buffer={60} ariaLabel="Streaming video" />
SolidJS
import { createSignal } from 'solid-js';
import { Progress } from 'material/solid';

export function Example() {
  const [value, setValue] = createSignal(30);
  const advance = () => setValue(75);

  return (
    <Progress value={value()} buffer={60} ariaLabel="Streaming video" />
  );
}

buffer draws how much is ready ahead of a linear value, as for streaming media. showLabel shows the percentage beside the indicator, and labelFormatter writes it differently. Recipes such as an upload with progress are planned for Showcase.

API

Options

variant

The form of the indicator

Type'linear' | 'circular'
Default'linear'
value

The value, from 0 to max

Typenumber
Default0
max

The value at completion

Typenumber
Default100
buffer

The buffered value of a linear indicator

Typenumber
Default0
indeterminate

Activity without a value

Typeboolean
Defaultfalse
shape

A flat or a wavy active indicator

Type'flat' | 'wavy'
Default'flat'
thickness

4px, 8px, or a number of pixels

Type'thin' | 'thick' | number
Default'thin'
size

The diameter of a circular indicator, from 24 to 240

Typenumber
Default40, 48 when wavy
showStopIndicator

The dot at the end of a determinate linear track

Typeboolean
Defaulttrue
showLabel

Shows the value as a label

Typeboolean
Defaultfalse
labelFormatter

Writes the label

Type(value, max) => string
Defaulta percentage
ariaLabel

What is in progress

Typestring
Default'Loading'
disabled

Whether it starts disabled

Typeboolean
Defaultfalse
class

Additional CSS classes

Typestring
Defaultundefined
prefix

Prefix for CSS class names

Typestring
Default'mtrl'

Methods

getValue() / setValue(value, animate?)

The value; animate is true by default

Parametersvalue: number, animate?: boolean
Returnsnumber / ProgressComponent
getMax()

The maximum

Parametersnone
Returnsnumber
getBuffer() / setBuffer(value)

The buffered value

Parametersvalue: number
Returnsnumber / ProgressComponent
isIndeterminate() / setIndeterminate(indeterminate)

Whether it is indeterminate

Parametersindeterminate: boolean
Returnsboolean / ProgressComponent
getShape() / setShape(shape)

The shape

Parametersshape: 'flat' | 'wavy'
Returnsstring / ProgressComponent
getThickness() / setThickness(thickness)

The thickness, read in pixels

Parametersthickness: 'thin' | 'thick' | number
Returnsnumber / ProgressComponent
getSize() / setSize(size)

A circular indicator's diameter

Parameterssize: number
Returnsnumber | undefined / ProgressComponent
showLabel() / hideLabel()

The label

Parametersnone
ReturnsProgressComponent
setLabelFormatter(formatter)

How the label is written

Parametersformatter: (value, max) => string
ReturnsProgressComponent
show() / hide() / isVisible()

Shows or hides it; hidden, it stops animating

Parametersnone
ReturnsProgressComponent / boolean
enable() / disable() / isDisabled()

The disabled state, with aria-disabled, set the same way at creation

Parametersnone
ReturnsProgressComponent / boolean
painted()

Resolves once it has been drawn

Parametersnone
ReturnsPromise<void>
on(event, handler) / off(event, handler)

Adds or removes a listener

Parametersevent: 'change' | 'complete', handler: Function
ReturnsProgressComponent
addClass(...classes)

Adds CSS classes

Parameters...classes: string[]
ReturnsProgressComponent
destroy()

Stops its animations and removes it

Parametersnone
Returnsvoid

Events

change

The value was set

Payload{ value, max }
complete

The value reached max: after the animation, or at once without one

Payload{ value, max }

The web component dispatches no events: its value and indeterminate properties are the live state, and its attributes the first one.

Styling

The indicator is drawn on a canvas, in the theme's colors: the active and stop indicators in --mtrl-sys-color-primary, the track in --mtrl-sys-color-secondary-container. They are read again when the theme changes.

.mtrl-progress, .mtrl-progress--linear, .mtrl-progress--circular { }
.mtrl-progress--indeterminate, .mtrl-progress--disabled { }
.mtrl-progress__canvas, .mtrl-progress__label { }

Measurements

Attribute Value
Track 4dp thin, 8dp thick; secondary-container
Active indicator primary, round caps
Gap between the indicator and the track 4dp
Stop indicator 4dp, primary
Circular 40dp, 48dp when wavy
Wave 3dp amplitude and 40dp wavelength on a linear indicator (20dp indeterminate); 1.6dp and 15dp on a 40dp circle, scaled with its size
Value change 500ms, linear
Label Label Medium, on-surface-variant