Skip to content
IndexRequest a UIAboutContact

Upload Progress & Retry

A file row with live percent, Cancel, and a Retry path when the upload fails.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Build a file upload progress row. It shows a file icon, the file name "report-final.pdf", the size, a thin determinate progress bar and a percent number. States: uploading (bar fills, Cancel link), done (green check, "Uploaded", no bar), failed (red message "Upload failed. Check your connection.", Retry button), cancelled (grey "Cancelled", Retry). Include a small switch "Fail at 60 percent" for testing. Light minimal style, rounded corners, 1 pixel borders, accessible: progress uses role progressbar with aria-valuenow, state changes are announced via aria-live, buttons have clear labels. Plain HTML, CSS and JavaScript.

About this pattern

Definition

An upload row shows file name, a determinate progress bar and the current state: waiting, uploading, done, failed or cancelled. Each state offers the right next action.

Purpose & UX principles

  • Percent plus a bar tells people exactly how long is left; Cancel gives control; Retry recovers from failures without starting over.
  • Announce completion and failure to screen readers; do not rely on colour alone.
  • Keep the file name visible and truncate it in the middle for long names.

Interaction states

  • Idle, uploading (percent rises), done (check), failed (error text and Retry), cancelled. The "Fail at 60%" switch makes the next upload fail so you can test the error path.

Motion specification

  • Bar width updates smoothly every 100ms; state icons fade in over 200ms.
  • Reduced motion: the bar still changes width but without easing transitions.

Responsive behaviour

  • Row stretches to the container; buttons stay at least 28px tall for touch.
  • On very narrow widths, drop the percent to under the name.

Code

HTML
<div class="bx"><div class="row"><div class="ic">PDF</div><div class="mid"><div class="top"><b>report-final.pdf</b><span id="pc">0%</span></div><div class="bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" id="bar"><i id="fill"></i></div><p class="st" id="st" aria-live="polite">Ready to upload · 2.4 MB</p></div></div>
<div class="act"><button id="go" type="button">Upload</button><button id="cn" type="button" hidden>Cancel</button></div><label class="sw"><input id="fl" type="checkbox"> Fail at 60%</label></div>

Related patterns

Progress Indicator

↗
Progress IndicatorLoading & Progress

Loader Variants

↗
Loader VariantsLoading & Progress

Toast

↗
ToastFeedback & Notifications