Skip to content

Loading Bar

The LoadingBar is a thin bar fixed to the top of the page. It tells people the app is busy, for example while a page navigates or while selected API calls are in flight.

The progress is simulated. The bar jumps in quickly, slows down as it nears 95%, and only reaches 100% when the work really finishes. Because of that it needs no progress data from the backend and works for any request.

Use it for page-level or background activity. For a measurable operation such as an upload or a pipeline run, use Progress. For content placeholders, use Skeleton.

Press Start in the example, wait a moment, then press Done. The demo uses an inline bar so it stays inside the example; in an app the bar is fixed to the top of the viewport.

How it behaves

BehaviorDefaultWhat it does
Show delay120 msWork that finishes faster never shows the bar, so quick requests do not flash it.
Minimum visible time300 msOnce shown, the bar stays at least this long so it does not blink.
Initial progress8%Where the bar starts when it appears.
Trickle250 msEvery step moves a small fraction of the remaining distance, so it slows down near the cap.
Progress cap95%Trickling never goes past this. Only finishing the work reaches 100%.
Completion200 msThe fill runs to 100%, then the bar fades out (200 ms) and rewinds while invisible.
Safety net30 sIf a task never calls done, the bar force-completes. Set maxDuration: 0 to disable.

All of these can be changed. See Customizing the timings.

Installation

import { LoadingBar, loadingBar } from '@harnessio/ui/components'
//...
// 1. Mount once, near the root of your app
return (
<>
<Outlet />
<LoadingBar />
</>
)
// 2. Start and stop it from anywhere
const key = loadingBar.start()
await doWork()
loadingBar.done(key)