Skip to content

Material 3

Components

Progress indicator

Progress indicators show the status of a process in real time.

9:30
Downloads
3 filesAbout 4 minutes left
Summer trip.zip55%
1.2 GB of 2.1 GB
Field notes.pdf80%
19 MB of 24 MB
Episode 12.mp315%
9 MB of 62 MB

Progress indicators show the status of an ongoing process, such as loading an app, submitting a form or saving updates.

  • Determinate indicators show known progress, and fill from 0% to 100%.
  • Indeterminate indicators show that a process is happening while the wait time is unknown.

When several items are loading, use a single progress indicator for the group. For a short wait, between 200ms and 5s, prefer a loading indicator.

A progress indicator comes as one of two components:

PartUse
LinearProgressIndicatorA bar, as wide as its container. Place it on the edge of a container.
CircularProgressIndicatorA ring, in an inline box of its size. Center it in an element.
import { CircularProgressIndicator, LinearProgressIndicator } from '@material-web/react'

Basic progress indicator

Use a LinearProgressIndicator or a CircularProgressIndicator to show the progress of a process, and name it with an aria-label.

import { CircularProgressIndicator, LinearProgressIndicator } from '@material-web/react'

export default function Basic() {
  return (
    <div className="flex w-80 flex-col items-center gap-space-400">
      <LinearProgressIndicator aria-label="Loading news article" value={40} />
      <CircularProgressIndicator aria-label="Refreshing page" shape="wavy" isIndeterminate />
    </div>
  )
}

An indicator is determinate unless isIndeterminate is set, and its value is 0 by default.

Label

Children are rendered inside the indicator. To show the value in the ring of a circular indicator, pass a function as children and center the text it returns over the indicator, as with absolute inset-0 in this example. The function receives percentage, valueText and isIndeterminate. See Children as a function.

72%
3 of 8
import { CircularProgressIndicator } from '@material-web/react'

export default function ValueText() {
  return (
    <>
      <CircularProgressIndicator aria-label="Storage used" size={96} value={72}>
        {({ valueText }) => (
          <span className="absolute inset-0 grid place-items-center text-label-lg">
            {valueText}
          </span>
        )}
      </CircularProgressIndicator>
      <CircularProgressIndicator
        aria-label="Uploading photos"
        size={96}
        value={3}
        maxValue={8}
        valueLabel="3 of 8"
      >
        {({ valueText }) => (
          <span className="absolute inset-0 grid place-items-center text-label-lg">
            {valueText}
          </span>
        )}
      </CircularProgressIndicator>
    </>
  )
}

To show a label or the value beside a linear indicator, write them next to it, and name the indicator by its visible label with aria-labelledby. A linear indicator is as wide as its container, so in a row, put it in an element that takes the room that is left.

Downloading update
40%
import { LinearProgressIndicator } from '@material-web/react'
import { useId } from 'react'

export default function LinearWithLabel() {
  const id = useId()
  const value = 40
  return (
    <div className="flex w-full max-w-96 flex-col gap-space-100">
      <span id={id} className="text-label-lg">
        Downloading update
      </span>
      <div className="flex items-center gap-space-200">
        <div className="min-w-0 flex-1">
          <LinearProgressIndicator aria-labelledby={id} value={value} />
        </div>
        <span className="text-label-lg text-on-surface-variant">{value}%</span>
      </div>
    </div>
  )
}

Value text

valueText is the text that the indicator reports for its value. An indicator reports its value to assistive technology as a percentage, such as 40%. Where the progress is not a percentage, set valueLabel to the text to report, or set formatOptions to format the value as another kind of number, as with React Aria's ProgressBar. A circular indicator takes both props too.

import { LinearProgressIndicator } from '@material-web/react'

export default function LinearValueText() {
  return (
    <div className="flex w-full max-w-96 flex-col gap-space-400">
      <LinearProgressIndicator
        aria-label="Uploading photos"
        value={3}
        maxValue={8}
        valueLabel="3 of 8 photos"
      />
      <LinearProgressIndicator
        aria-label="Downloading update"
        value={12}
        maxValue={20}
        formatOptions={{ style: 'unit', unit: 'megabyte' }}
      />
    </div>
  )
}

Determinate

Set value to the progress made. A determinate indicator must accurately represent the progress of what it measures.

import { Button, CircularProgressIndicator } from '@material-web/react'
import { useState } from 'react'

export default function CircularDeterminate() {
  const [value, setValue] = useState(40)
  return (
    <div className="flex flex-col items-center gap-space-300">
      <CircularProgressIndicator aria-label="Installing update" value={value} />
      <Button variant="tonal" onPress={() => setValue(value >= 100 ? 0 : value + 20)}>
        {value >= 100 ? 'Start over' : 'Add 20%'}
      </Button>
    </div>
  )
}
import { Button, LinearProgressIndicator } from '@material-web/react'
import { useState } from 'react'

export default function LinearDeterminate() {
  const [value, setValue] = useState(40)
  return (
    <div className="flex w-full max-w-96 flex-col items-center gap-space-300">
      <LinearProgressIndicator aria-label="Downloading update" value={value} />
      <Button variant="tonal" onPress={() => setValue(value >= 100 ? 0 : value + 20)}>
        {value >= 100 ? 'Start over' : 'Add 20%'}
      </Button>
    </div>
  )
}

Custom scale

A value is kept between minValue and maxValue, which are 0 and 100 by default. Set them to measure the progress on another scale. The indicator fills by the share of the range that the value has reached: step 2 of 5 fills 40% of the ring. A linear indicator takes minValue and maxValue too.

import { CircularProgressIndicator } from '@material-web/react'

export default function CircularCustomScale() {
  return (
    <>
      <CircularProgressIndicator aria-label="Setting up, step 2 of 5" value={2} maxValue={5} />
      <CircularProgressIndicator
        aria-label="Preheating the oven"
        value={110}
        minValue={20}
        maxValue={200}
      />
    </>
  )
}

Indeterminate

Set isIndeterminate to show that a process is happening while the wait time is unknown.

import { CircularProgressIndicator } from '@material-web/react'

export default function CircularIndeterminate() {
  return <CircularProgressIndicator aria-label="Refreshing page" isIndeterminate />
}
import { LinearProgressIndicator } from '@material-web/react'

export default function LinearIndeterminate() {
  return (
    <div className="w-full max-w-96">
      <LinearProgressIndicator aria-label="Loading news article" isIndeterminate />
    </div>
  )
}

Indeterminate to determinate

As more about a process becomes known, change the indicator from indeterminate to determinate: clear isIndeterminate and set a value.

import { Button, CircularProgressIndicator, LinearProgressIndicator } from '@material-web/react'
import { useState } from 'react'

export default function ToDeterminate() {
  const [isLoaded, setLoaded] = useState(false)
  return (
    <div className="flex w-full max-w-96 flex-col items-center gap-space-300">
      <LinearProgressIndicator
        aria-label="Loading episodes"
        isIndeterminate={!isLoaded}
        value={100}
      />
      <CircularProgressIndicator
        aria-label="Loading artwork"
        isIndeterminate={!isLoaded}
        value={100}
      />
      <Button variant="tonal" onPress={() => setLoaded(!isLoaded)}>
        {isLoaded ? 'Load again' : 'Finish loading'}
      </Button>
    </div>
  )
}

Color

The active indicator takes the text color, which is primary by default. To use another color role, pass its text color class in className. The track keeps its secondary-container color. On a linear indicator, the stop indicator takes the same color as the active indicator.

import { CircularProgressIndicator } from '@material-web/react'

export default function CircularColor() {
  return (
    <>
      <CircularProgressIndicator
        aria-label="Loading, secondary"
        isIndeterminate
        className="text-secondary"
      />
      <CircularProgressIndicator
        aria-label="Loading, tertiary"
        isIndeterminate
        className="text-tertiary"
      />
      <CircularProgressIndicator
        aria-label="Loading, error"
        isIndeterminate
        className="text-error"
      />
    </>
  )
}
import { LinearProgressIndicator } from '@material-web/react'

export default function LinearColor() {
  return (
    <div className="flex w-full max-w-96 flex-col gap-space-400">
      <LinearProgressIndicator
        aria-label="Loading, secondary"
        isIndeterminate
        className="text-secondary"
      />
      <LinearProgressIndicator
        aria-label="Loading, tertiary"
        isIndeterminate
        className="text-tertiary"
      />
      <LinearProgressIndicator aria-label="Loading, error" value={40} className="text-error" />
    </div>
  )
}

Sizes

Set size on a circular indicator to its size in dp, from 24 to 240. A size outside the range is brought back to its nearest end. The stroke and the wave scale with the size.

Without size, a circular indicator is 48dp at the default thickness, and a thicker stroke adds to it.

import { CircularProgressIndicator } from '@material-web/react'

export default function Sizes() {
  return (
    <>
      <CircularProgressIndicator aria-label="Loading, 24dp" shape="wavy" size={24} value={40} />
      <CircularProgressIndicator aria-label="Loading, 48dp" shape="wavy" size={48} value={40} />
      <CircularProgressIndicator aria-label="Loading, 96dp" shape="wavy" size={96} value={40} />
      <CircularProgressIndicator aria-label="Loading, 240dp" shape="wavy" size={240} value={40} />
    </>
  )
}

Shapes

Set shape to flat (the default) or wavy, which gives the active indicator a wave. The wavy shape can make a longer process feel less static, and suits a more expressive style.

A wavy linear indicator is as tall as its wave. On a wavy circular indicator, the crests of the wave reach past the indicator's size by the amplitude.

import { CircularProgressIndicator, LinearProgressIndicator } from '@material-web/react'

export default function Shapes() {
  return (
    <div className="flex w-full max-w-96 flex-col items-center gap-space-400">
      <LinearProgressIndicator aria-label="Loading, flat" shape="flat" value={40} />
      <LinearProgressIndicator aria-label="Loading, wavy" shape="wavy" value={40} />
      <LinearProgressIndicator aria-label="Loading, wavy" shape="wavy" isIndeterminate />
      <div className="flex gap-space-400">
        <CircularProgressIndicator aria-label="Refreshing, flat" shape="flat" value={40} />
        <CircularProgressIndicator aria-label="Refreshing, wavy" shape="wavy" value={40} />
        <CircularProgressIndicator aria-label="Refreshing, wavy" shape="wavy" isIndeterminate />
      </div>
    </div>
  )
}

On a determinate indicator, the wave shows while the progress is above 10% and below 95%. To change the wave, see Amplitude and wavelength.

Track and stop indicator

The track is the part of the ring or the bar that the active indicator has not reached. Set showTrack={false} to remove it, as in a button.

import { CircularProgressIndicator } from '@material-web/react'

export default function CircularTrack() {
  return (
    <>
      <CircularProgressIndicator aria-label="Loading news article" value={40} />
      <CircularProgressIndicator aria-label="Loading, no track" value={40} showTrack={false} />
      <CircularProgressIndicator
        aria-label="Refreshing, no track"
        isIndeterminate
        showTrack={false}
      />
    </>
  )
}

A determinate linear indicator ends in a stop indicator. Set showStopIndicator={false} to remove it, only where the track has a contrast of at least 3:1 with the surfaces around it. An indeterminate or a circular indicator has no stop indicator.

import { LinearProgressIndicator } from '@material-web/react'

export default function StopAndTrack() {
  return (
    <div className="flex w-full max-w-96 flex-col gap-space-400">
      <LinearProgressIndicator aria-label="Loading news article" value={40} />
      <LinearProgressIndicator
        aria-label="Loading, no stop indicator"
        value={40}
        showStopIndicator={false}
      />
      <LinearProgressIndicator aria-label="Loading, no track" value={40} showTrack={false} />
    </div>
  )
}

Placement

Place a linear indicator on the edge of a container, and center a circular one in an element. In this example, a linear indicator runs along the top edge of a container that is loading, inset 4dp from its sides.

My episodes
import { LinearProgressIndicator } from '@material-web/react'

export default function OnContainer() {
  return (
    <div className="w-full max-w-96 rounded-shape-lg bg-surface-container-highest">
      <div className="px-space-50 pt-space-50">
        <LinearProgressIndicator aria-label="Loading my episodes" shape="wavy" value={35} />
      </div>
      <div className="p-space-200 text-title-lg">My episodes</div>
    </div>
  )
}

Right to left

In a right-to-left layout, a linear indicator fills from the right. A circular indicator still fills clockwise.

import { CircularProgressIndicator, LinearProgressIndicator } from '@material-web/react'

export default function RightToLeft() {
  return (
    <div dir="rtl" className="flex w-full max-w-96 items-center gap-space-400">
      <LinearProgressIndicator aria-label="Loading news article" shape="wavy" value={40} />
      <CircularProgressIndicator aria-label="Refreshing page" shape="wavy" value={40} />
    </div>
  )
}

In a button

In a button, remove the track with showTrack={false} and give the indicator the label's color with className="text-current". In a very small button, use the flat shape, since the wave is not as visible at that size.

When the button's label already says what is happening, hide the indicator from assistive technology by wrapping it in an element with aria-hidden, and still give the indicator an aria-label.

Note: An aria-hidden set on the indicator itself is not applied.

import { Button, CircularProgressIndicator } from '@material-web/react'

export default function InButton() {
  return (
    <>
      <Button>
        <span aria-hidden className="flex">
          <CircularProgressIndicator
            aria-label="Saving"
            isIndeterminate
            size={24}
            showTrack={false}
            className="text-current"
          />
        </span>
        Saving
      </Button>
      <Button variant="outlined">
        <span aria-hidden className="flex">
          <CircularProgressIndicator
            aria-label="Checking for updates"
            isIndeterminate
            size={24}
            showTrack={false}
            className="text-current"
          />
        </span>
        Checking for updates
      </Button>
    </>
  )
}

While the button's action is in progress, set its isPending instead: a pending button shows a loading indicator of its own, alone, and ignores presses. See Loading.

Delaying appearance

To keep an indicator from flashing on a process that ends at once, render it only after the process has run for a moment. In this example, the indicator appears after one second: stop the loading before that, and it is never shown.

import { Button, LinearProgressIndicator } from '@material-web/react'
import { useRef, useState } from 'react'

export default function Delay() {
  const [status, setStatus] = useState<'idle' | 'loading' | 'slow'>('idle')
  const timer = useRef<ReturnType<typeof setTimeout>>(undefined)

  const start = () => {
    setStatus('loading')
    // The indicator appears once the process has run for a second.
    timer.current = setTimeout(() => setStatus('slow'), 1000)
  }
  const stop = () => {
    clearTimeout(timer.current)
    setStatus('idle')
  }

  return (
    <div className="flex w-full max-w-96 flex-col items-center gap-space-300">
      <div className="h-space-50 w-full">
        {status === 'slow' && (
          <LinearProgressIndicator aria-label="Loading results" isIndeterminate />
        )}
      </div>
      <Button variant="tonal" onPress={status === 'idle' ? start : stop}>
        {status === 'idle' ? 'Start loading' : 'Stop loading'}
      </Button>
    </div>
  )
}

Customization

Pass classes in className to restyle one indicator. A class of yours replaces the indicator's own class for the same property. See Styling for the classes and the theme.

  • Width: A linear indicator is as wide as its container. Pass a width class, such as w-48, to set its width.
  • Color: Pass a text color class for the active indicator, as in Color.
  • Track color: The track is not reached by className. To change its color, set the secondary-container color role on the indicator. See Theme.
  • Functions: children, className and style can be functions of percentage, valueText and isIndeterminate. See Children as a function.
  • Every indicator: To restyle all the indicators at once, change the theme.

Thickness

Set thickness to the thickness of the stroke in dp. The default is 4.

import { CircularProgressIndicator, LinearProgressIndicator } from '@material-web/react'

export default function Thickness() {
  return (
    <div className="flex w-full max-w-96 flex-col items-center gap-space-400">
      <LinearProgressIndicator aria-label="Loading, 4dp" value={40} />
      <LinearProgressIndicator aria-label="Loading, 8dp" thickness={8} value={40} />
      <LinearProgressIndicator
        aria-label="Loading, 8dp, wavy"
        thickness={8}
        shape="wavy"
        value={40}
      />
      <div className="flex gap-space-400">
        <CircularProgressIndicator aria-label="Refreshing, 4dp" value={40} />
        <CircularProgressIndicator aria-label="Refreshing, 8dp" thickness={8} value={40} />
        <CircularProgressIndicator
          aria-label="Refreshing, 8dp, wavy"
          thickness={8}
          shape="wavy"
          value={40}
        />
      </div>
    </div>
  )
}

Amplitude and wavelength

On a wavy indicator, set amplitude and wavelength in dp. The amplitude is measured from the center of the resting position to the center of the peak, and the wavelength between two adjacent peaks.

IndicatorAmplitudeWavelength
Linear, determinate340
Linear, indeterminate320
Circular1.615

These are the defaults. A wavelength shorter than 8dp, or shorter than the thickness, is raised to that length.

import { CircularProgressIndicator, LinearProgressIndicator } from '@material-web/react'

export default function Wave() {
  return (
    <div className="flex w-full max-w-96 flex-col items-center gap-space-400">
      <LinearProgressIndicator aria-label="Loading" shape="wavy" value={60} />
      <LinearProgressIndicator
        aria-label="Loading, a taller and shorter wave"
        shape="wavy"
        amplitude={6}
        wavelength={24}
        value={60}
      />
      <div className="flex gap-space-400">
        <CircularProgressIndicator aria-label="Refreshing" shape="wavy" value={60} />
        <CircularProgressIndicator
          aria-label="Refreshing, a longer wave"
          shape="wavy"
          wavelength={30}
          value={60}
        />
      </div>
    </div>
  )
}

Limitations

Hidden indicators

An indicator does not apply an aria-hidden of its own. To hide it from assistive technology, set aria-hidden on an element around it, as in a button.

Server rendering

A progress indicator is drawn by script. On a server-rendered page, a linear indicator stays empty and a circular one stands still until the page has hydrated. Where an indicator must move before that, use a loading indicator, which does not wait for the script.