React + MotionLoaders

Indeterminate progress bar

A slim bar with a segment that keeps sliding across, for waits when you don’t know how long they’ll take.

Settings

10px
1.6s

Code

import { motion } from "framer-motion";

interface ProgressBarProps {
  color?: string;
  /** Grosor de la barra en px. */
  size?: number;
  /** Duración de un recorrido en segundos. */
  speed?: number;
}

export default function ProgressBar({
  color = "#0071e3",
  size = 10,
  speed = 1.6,
}: ProgressBarProps) {
  return (
    <div
      role="progressbar"
      aria-label="Loading"
      className="w-56 overflow-hidden rounded-full bg-black/5 dark:bg-white/10"
      style={{ height: size }}
    >
      <motion.div
        className="h-full rounded-full"
        style={{ backgroundColor: color }}
        initial={false}
        animate={{ x: ["-100%", "220%"] }}
        transition={{ duration: speed, repeat: Infinity, ease: "easeInOut" }}
      />
    </div>
  );
}

Prompt for AI

Paste it into ChatGPT, Claude or Cursor and it will adapt the block to your project with these settings, even if you don’t use React.

More in Loaders

Where to use it

An indeterminate progress bar says “working on it” without promising a time. It fits the top edge of a web app while the next page loads, the header of a dashboard refreshing its charts or the space under the search box of a flight comparison site. It stays out of the way and still shows life.

Thin works best: three or four pixels pinned to the top of the screen are barely noticed, yet reassuring. As soon as you know the real percentage, switch to a determinate bar so people can see the end coming.