Upload Progress

A file upload row with filename, percentage, progress bar, and cancel button.

project-mockup.fig

65% · 2.1 MB of 3.2 MB

Tailwind CSS
<div class="w-full max-w-sm rounded-xl border border-slate-200 bg-white p-4 shadow-sm">
  <div class="flex items-start gap-3">
    <div class="grid h-10 w-10 shrink-0 place-items-center rounded-lg bg-indigo-50 text-indigo-600">
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-5 w-5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6"/></svg>
    </div>
    <div class="min-w-0 flex-1">
      <div class="flex items-center justify-between gap-2">
        <p class="truncate text-sm font-medium text-slate-900">project-mockup.fig</p>
        <button type="button" aria-label="Cancel upload" class="shrink-0 rounded-md p-1 text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-600">
          <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" class="h-4 w-4"><path d="M18 6 6 18M6 6l12 12"/></svg>
        </button>
      </div>
      <p class="mt-0.5 text-xs text-slate-500">65% &middot; 2.1 MB of 3.2 MB</p>
      <div class="mt-2 h-2 overflow-hidden rounded-full bg-slate-100">
        <div class="h-full w-[65%] rounded-full bg-indigo-600 transition-[width] duration-300"></div>
      </div>
    </div>
  </div>
</div>

Free to use in personal and commercial projects. No attribution required.

Variants

Same component, different looks. Preview each one live and copy the code you like.

Complete

Show the complete state with a Done badge so users know the file is safe.

project-mockup.fig

Done

3.2 MB · uploaded just now

Tailwind CSS

Image file

The image variant with a gradient thumbnail suits media uploads in CMS and gallery tools.

hero-banner.png

32% · 1.4 MB of 4.4 MB

Tailwind CSS

Failed

The failed state with a retry button keeps users from losing their place after a network drop.

project-mockup.fig

Upload failed · connection lost

Tailwind CSS

About this upload progress

Uploads are waiting, and waiting needs a progress report. This file row shows everything a user needs mid-upload: which file, how far along, how much is left, and a way out with the cancel button.

The layout is a flex row with a file-type icon, then a flexible column that truncates long filenames so the row never breaks on narrow screens. The bar is a rounded track with an indigo fill at 65 percent width, and transition-[width] smooths each update as your upload code bumps the percentage. The cancel button is a real button with an aria-label, not a decorative span.

Use it in upload queues, attachment lists, and import flows. Update the width style and the percentage text together from your upload handler, and swap the bar to green with a check when the upload completes.

Uploads are waiting, and waiting without information feels endless. A bare spinner cannot say whether a 200MB video is 5 percent or 95 percent done, so users guess, and guessing leads to cancelled uploads and rage refreshes. A proper upload row reports the file, the percentage, and an escape hatch, turning an anxious wait into a monitored one.

The row is flex: a file-type icon, then a flexible column that truncates long filenames so narrow screens never break the layout. The bar is a rounded track with the fill width set as a percentage, and transition-[width] smooths each update as the upload code bumps the number. The cancel control is a real button with an accessible name, not a decorative span.

For multiple files, render one row per file with its own bar and cancel button; a single blended percentage hides which file is stuck. Sort the list with active uploads first and finished ones collapsing into a quiet done state. When a file fails, keep its row visible in red with a retry button instead of vanishing it; disappearing failures teach users not to trust the uploader. Cap concurrent uploads at three; more than that and every file crawls.

The cruelest bug is the bar that hits 100 percent the moment the bytes finish, while the server still needs thirty seconds to process the file. The user closes the tab, the processing dies, and support gets a ticket about a completed upload that never appeared. Cap the visible bar around 95 percent during transfer, then flip to an explicit Processing state until the server confirms.

Where to use it

  • ✓ File upload queues
  • ✓ Attachment pickers
  • ✓ CSV import flows
  • ✓ Media library uploads

Customization tips

Change the icon background per file type: red for PDF, green for sheets, blue for docs. Add a pause button next to cancel for large files. Show an error state by turning the bar red and replacing the percentage with a retry link.

Design notes

When to use

An upload row suits file uploads where users wait and want specifics: which file, how far along, and a way out. Showing the filename plus the percentage answers is it stuck or moving without any guessing. The cancel button matters because a large upload with no escape hatch makes users close the whole tab.

What to avoid

Do not show only a percentage with no filename when multiple files upload, users cannot tell which one stalled. Avoid jumping the bar from 10 to 100 percent instantly, fake progress is worse than an honest spinner. And do not hide the cancel button behind a hover menu, it must be visible the whole time.

Accessibility

Give the bar role progressbar with aria-valuenow and include the filename in its label so multi-file uploads stay distinguishable. The cancel button needs a clear accessible name like cancel upload of report.pdf.

Frequently asked questions

How do I show upload progress with Tailwind?

Use a rounded track div with a child fill div whose width you update from JavaScript. Add transition-[width] so it animates smoothly between updates, and keep a text percentage for screen readers.

Why is the filename truncated?

truncate with min-w-0 on the flex child keeps long names on one line without pushing the cancel button off screen. Pair it with a title attribute so the full name shows on hover.

Should the cancel button be a real button?

Yes. A real button is keyboard-focusable and announces its purpose with aria-label. A clickable div or span excludes keyboard users from cancelling the upload.

How do I connect the bar to a real file upload?

Use XMLHttpRequest and listen to upload.onprogress, then set the fill width to event.loaded divided by event.total times 100. The Fetch API does not expose upload progress, which is why XHR is still the standard choice here. Update a CSS variable or inline width on each progress event for smooth motion.

How do I make the upload progress accessible?

Add role progressbar with aria-valuemin 0, aria-valuemax 100, and update aria-valuenow on each progress tick. Screen readers will announce the percentage as it climbs. Throttle the announcements by rounding to whole numbers so rapid updates do not flood the live region.

How do I add animated stripes to the progress fill?

Layer a repeating-linear-gradient at 45 degrees over the fill color and animate background-position in a loop to make the stripes crawl. Keep the stripe contrast subtle, around 10% lighter than the base, so the percentage text stays readable. Pause the stripe motion under prefers-reduced-motion.