FRENVersion française

Feedback

Progress bar

Barre de progression

Demo

Loading demo…

A bar that fills up as a task moves forward: upload, export, install. Determinate, it shows how far along you are; indeterminate, it only says things are moving. It helps people decide whether to wait or come back later.

Story

Did you know

A bar that speeds up near the end feels shorter than one that slows down, for the same duration. Chris Harrison showed this in 2007. A bar stuck at 99% is the worst possible ending.

Timeline

  1. 1985Brad Myers publishes a CHI paper on the value of percent-done progress indicators.
  2. 1993Jakob Nielsen sets out the 0.1 s, 1 s and 10 s limits in Usability Engineering.
  3. 2007Chris Harrison and colleagues study how bars are perceived (UIST 2007).
  4. 2010s<progress> and <meter> arrive with HTML5; slim top-of-page bars (YouTube, NProgress) spread.

Vocabulary

Names

FR
Barre de progression, progression, jauge, barre de chargement
EN
Progress bar, loading bar, progress indicator, determinate progress, indeterminate progress, top loading bar

Common uses

  • File uploads
  • Export, install, update
  • Slim top-of-page bar during navigation
  • Long job split into steps

Often paired with

The components it usually sits with, by page type, in reading order.

Code

<input type="file" id="file">
<progress id="bar" max="100" value="0" aria-label="Upload progress" hidden></progress>
<p id="status" role="status"></p>

<script>
  const bar = document.querySelector('#bar')
  const status = document.querySelector('#status')

  document.querySelector('#file').addEventListener('change', (e) => {
    const file = e.target.files[0]
    if (!file) return
    const xhr = new XMLHttpRequest()
    bar.hidden = false
    bar.value = 0
    status.textContent = 'Uploading…'
    // fetch() has no upload progress event: XHR does
    xhr.upload.onprogress = (ev) => {
      if (ev.lengthComputable) bar.value = Math.round((ev.loaded / ev.total) * 100)
    }
    xhr.onload = () => { status.textContent = xhr.status < 300 ? 'Upload complete' : 'Upload failed' }
    xhr.onerror = () => { status.textContent = 'Upload failed' }
    xhr.open('POST', '/api/upload')
    xhr.send(file)
  })
</script>

Good to know

  • <progress> without a value attribute is indeterminate. With value and max, it becomes determinate. To go back to indeterminate, remove the attribute: value="0" shows an empty bar.
  • <meter> is not a progress bar. It measures a value within a known range (disk usage, password strength) and handles thresholds with low, high and optimum.
  • fetch() gives you no progress event for the request body. For uploads, use XMLHttpRequest and xhr.upload.onprogress, and check lengthComputable.
  • Jakob Nielsen's limits: under 1 s show nothing, 1 to 10 s a spinner, over 10 s a bar with a percentage. Slim top-of-page bars (NProgress, YouTube) are simulated: they creep up to about 90% on their own, then jump to 100% when done.

Accessibility

Must have

  • Give the bar a name: <label for> or aria-label on <progress>. For a custom one, role="progressbar" with aria-valuenow, aria-valuemin, aria-valuemax and a name. Without aria-valuenow, it is indeterminate.
  • Announce the start, the end and any failure in a separate role="status" region that exists from page load. The bar itself should not be a live region.

Often forgotten

  • Don't announce every percent. Screen readers read the value when people reach the bar; if you want more, announce in steps (25%, 50%, 75%).
  • The filled part needs a 3:1 contrast with the track (WCAG 1.4.11, non-text contrast).
  • Don't use a <meter> instead: it exposes a meter role, not progress.

Nice to have

  • aria-valuetext for a meaningful value: "3 of 10 files", "2 minutes left".
  • Under prefers-reduced-motion, freeze the indeterminate animation and keep the "In progress…" text.

Who uses it