Live File Upload Progress
Percentage straight from the XHR progress event, tabular-nums readout, and a green completion state. The template every upload form should start from.
Create a single-file upload progress bar bound to real XHR progress events. The track is h-2 rounded-full bg-zinc-200 with an indigo-600 fill whose width equals Math.min(100, Math.round(loaded / total * 100)) from each progress event — no timer-based increments. Show the percentage right of the bar in tabular-nums text-sm, the filename above it, and at 100% transition the fill to green-500 over 300ms and swap the label to an "Uploaded" check. Set role="progressbar" with aria-valuemin, aria-valuemax, aria-valuenow, and aria-valuetext like "64 percent uploaded". Disable the submit button while in flight, and on error freeze the bar at its last value, turn the fill red-500, show the error message, and offer a Retry button that restarts the same upload.




