Progress bar
Also called progress indicator or loading bar
A horizontal bar that fills from left to right to show how much of a task is done, or slides in a loop while the total is still unknown.
import { motion, useReducedMotion } from 'motion/react';
import { Progress } from '@base-ui/react/progress';
type Props = { fileName: string; percent: number | null };
// Base UI adds role='progressbar' and aria-valuenow; `null` means the total is unknown.
export function UploadProgress({ fileName, percent }: Props) {
const reduceMotion = useReducedMotion();
return (
<Progress.Root
value={percent}
className='grid w-72 grid-cols-[1fr_auto] gap-x-3 gap-y-2 text-sm'
>
<Progress.Label className='truncate font-medium'>
{fileName}
</Progress.Label>
<Progress.Value className='text-muted-foreground tabular-nums data-complete:text-emerald-600'>
{(formatted) =>
percent === null
? 'Preparing…'
: percent === 100
? '✓ Done'
: formatted
}
</Progress.Value>
<Progress.Track className='col-span-2 h-1.5 overflow-hidden rounded-full bg-muted'>
{percent === null ? (
// Indeterminate: a 30% segment slides across the track every 1.2s.
<motion.div
className='h-full w-[30%] rounded-full bg-blue-500'
animate={
reduceMotion
? { opacity: [0.4, 1, 0.4] }
: { x: ['-100%', '333%'] }
}
transition={{ duration: 1.2, ease: 'easeInOut', repeat: Infinity }}
/>
) : (
<Progress.Indicator
className='h-full origin-left rounded-full bg-blue-500 transition-transform duration-300 ease-out data-complete:bg-emerald-500'
// Base UI sizes the fill with width; scaleX animates it on the GPU instead.
style={{ width: '100%', transform: `scaleX(${percent / 100})` }}
/>
)}
</Progress.Track>
</Progress.Root>
);
}Show upload progress under each file: a 6px rounded track with a blue fill that grows with the percentage uploaded, the percentage as text on the right, and a green check when it reaches 100%. While the upload is being prepared and the size is unknown, show an indeterminate bar where a 30% wide segment slides across every 1.2s. Animate the fill with transform: scaleX and add role="progressbar" with aria-valuenow.
Paste into Layerwise or any AI coding tool.
What is Progress bar?
A progress bar is a track with a fill that grows as a task advances. A determinate bar knows the amount of work, such as bytes uploaded or steps finished, and shows it as a percentage. An indeterminate bar does not know yet, so a short segment slides along the track in a loop.
Use a determinate bar for anything that takes more than a few seconds and can be measured: file uploads, exports, installs, imports. Seeing the fill move and knowing the task is 70% done keeps people patient far longer than a spinner. Switch from indeterminate to determinate as soon as you know the total.
Animate the fill with transform: scaleX() for smooth motion, keep it moving steadily, and avoid parking it at 99%. Use the native <progress> element or role="progressbar" with aria-valuenow, and show the percentage as text as well.
Often confused with
- Spinner
- A spinner only says the app is busy. A progress bar shows how much is done, so use it whenever you can measure the work.
- Scroll progress bar
- A scroll progress bar shows how far a reader has scrolled down a page. A progress bar tracks a task such as an upload.
Related terms
All termsSpinner
A small looping animation, usually a rotating ring, that shows the app is busy with a short task of unknown length.
Loading state
The view a screen shows while its data is on the way, designed together with the outcomes that follow: loaded, empty, or error.
Stepper
A multi-step flow with a row of numbered steps, like Account, Profile, Done, that shows where you are and how many steps are left.
Perceived performance
How fast an app feels to people, which skeleton screens, instant feedback, and progressive loading can improve even when the real wait stays the same.
Build it with Layerwise
Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.