Indeterminate Bar

A sliding bar like YouTube's top loader.

Tailwind CSS
<div class="w-48 h-1.5 rounded-full bg-slate-200 overflow-hidden" role="status" aria-label="Loading">
  <div class="h-full w-1/3 rounded-full bg-indigo-600 animate-[slidebar_1.2s_ease-in-out_infinite]"></div>
</div>
<style>
@keyframes slidebar {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}
</style>

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.

Gradient

Gradient bar for branded loading that matches a colorful identity.

Tailwind CSS

Pink wide

Wider track in pink for bold playful products.

Tailwind CSS

Thin minimal

Hairline neutral bar for minimal interfaces where loading should whisper.

Tailwind CSS

About this indeterminate bar

The indeterminate bar is YouTube's signature loader: a short bar sliding across a thin track at the top of the page. It says 'working' without claiming progress it cannot measure. This css bar loader rebuilds it with a custom slidebar keyframe.

The bar is w-1/3 inside an overflow-hidden track, animating translateX from -100% to 300%. The 1.2s ease-in-out loop feels smooth, not mechanical. It is the honest loader for operations of unknown duration.

Place it fixed at the top of the viewport (fixed top-0 left-0 right-0) for page-level loading, or inline for section loading. The thin 6px height keeps it unobtrusive.

The most anxious wait on the web is the page transition: the user clicked, nothing visibly happens, and the old page still sits there. Did the click register? Is the next page coming? A thin bar at the top of the viewport answers both questions with a handful of pixels. It is why YouTube, GitHub, and countless single-page apps show one during route changes: maximum reassurance, minimum chrome.

A custom @keyframes slidebar drives a w-1/3 bar from translateX(-100%) to translateX(300%) inside an overflow-hidden track. Starting at -100% parks the bar fully left of the track; ending at 300% carries it fully past the right edge, compensating for the bar's own width so it never visibly pops. The animate-[slidebar_1.2s_ease-in-out_infinite] utility wires the arbitrary keyframe into Tailwind, and the ease-in-out makes each pass feel smooth rather than mechanical.

Thin is the point, so stay at h-1 or h-1.5; a thicker bar starts reading as a progress claim. Paint the bar in the brand color but keep the track neutral (bg-slate-200) so the motion, not the decoration, carries the meaning. For section-level loading, drop the fixed positioning and let the bar sit inline directly above the content it guards.

The mistake is leaving the bar mounted after loading finishes. If the completion event fires before the animation's first frame, or an error path forgets to clear it, a frozen bar sits at the top of the page forever, quietly telling every visitor the site is stuck. Tie the bar's visibility to real loading state with cleanup on both success and error, never to the animation itself.

Where to use it

  • ✓ Page top loaders
  • ✓ Route transitions
  • ✓ File processing
  • ✓ Search operations

Customization tips

Fix to viewport top for global loading. Adjust the 1.2s duration for speed. Use your brand color instead of indigo. The w-1/3 bar width affects the feel; narrower feels faster.

Design notes

When to use

Use it for page level loading of unknown duration: route transitions, search operations, and file processing. Fixed to the top of the viewport like the familiar video site pattern, it says working without claiming progress it cannot measure. The thin bar stays out of the way.

What to avoid

Do not use it where you can measure real progress; a determinate bar with a percentage is always more honest. Do not place it where it overlaps navigation or covers content on small screens.

Accessibility

Add role=status and an accessible label so the loading state is announced. Since the bar never completes, pair it with text like Loading results for screen reader users who cannot see the motion.

Frequently asked questions

How does the YouTube-style loader work?

A short bar inside an overflow-hidden track animates translateX from -100% to 300% on a loop. The bar never claims progress, just activity.

Where should I place a top loader?

Fixed to the top of the viewport (fixed top-0) with high z-index. It should overlay content, not push it down.

Bar vs spinner for page loads?

Top bars suit page/route transitions where a centered spinner would feel disconnected. Spinners suit inline section loading.

How do I show real progress on the top loading bar instead of a fake animation?

Drive the bar's width with JavaScript as your page or request progresses. For page loads, tie it to router events or document readiness stages; for uploads, use the xhr upload progress event. The bar here uses scaleX, so set the transform scale from 0 to 1 based on the actual percentage.

Why does my top loader bar leave a gap on the right side?

The bar is animating from a left scale origin but its width is not full, or the parent has padding. Make the bar fixed at the top with left-0 and w-full, and animate scaleX with origin-left. That way the bar always spans edge to edge as it fills.

Should the loading bar disappear instantly or fade out?

Fade it out over 200 to 300ms after it reaches 100 percent. An instant vanish feels abrupt and can make users doubt the load finished. Keep the bar at full width briefly, then fade the opacity to zero before removing it from the DOM.

Customize it with our tools