Malay Patel

Progress

Component

About

Progress as a bar, a ring, a segmented breakdown and a list of steps. Values ease on a spring so fast updates never stutter, numbers roll, and finishing draws a check. Free component from uibrik (uibrik.com).

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Progress to your project and fits it to your theme.

Code

How Progress is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import { Progress, type ProgressSegment } from "@/components/ui/progress";
import { useEffect, useState } from "react";

const FILE_MB = 480;
const STEPS = ["Upload file", "Validate rows", "Match columns", "Import records", "Build search index"];
const ROWS = 12480;

const STORAGE: ProgressSegment[] = [
  { label: "Photos", value: 82.4 },
  { label: "Backups", value: 31.2 },
  { label: "Documents", value: 18.9 },
  { label: "Messages", value: 9.4 },
  { label: "Mail", value: 6.8 },
];

// One clock drives every variant: an export that loops, storage that drifts, an import that walks its steps.
function useClock(ms: number) {
  const [t, setT] = useState(0);
  useEffect(() => {
    const id = setInterval(() => setT((n) => n + 1), ms);
    return () => clearInterval(id);
  }, [ms]);
  return t;
}

const { show, indeterminate, thickness, ...props } = {
  show: "all" as "all" | "bar" | "ring" | "segments" | "steps",
  showValue: true,
  thickness: 8,
  orientation: "auto" as "auto" | "vertical" | "horizontal",
  indeterminate: false,
};

export default function Demo() {
  const t = useClock(400);

  // Export: 0–100 over ~11s, a short rest at 100, then again.
  const cycle = t % 32;
  const exportPct = Math.min(100, cycle * 3.6 + (cycle ? Math.sin(cycle) * 1.5 : 0));
  const sent = (exportPct / 100) * FILE_MB;
  const left = Math.max(0, Math.round((FILE_MB - sent) / 42));

  // Daily goal ring creeps up and resets.
  const ring = Math.min(100, ((t % 60) / 44) * 100);

  // Storage: photos and messages grow a little, then settle back.
  const wave = Math.sin(t / 6);
  const storage = STORAGE.map((s, i) => ({ ...s, value: +(s.value + (i === 0 ? wave * 9 : i === 3 ? Math.cos(t / 5) * 3 : 0)).toFixed(1) }));

  // Import: each step takes ~10 ticks, then everything holds before restarting.
  const at = t % 64;
  const current = Math.min(STEPS.length, Math.floor(at / 10));
  const stepProgress = (at % 10) / 10;
  const rows = Math.round(ROWS * (current > 1 ? 1 : current === 1 ? stepProgress : 0));
  const detail = (i: number) =>
    i === 0 ? (current > 0 ? "customers.csv · 8.2 MB" : `${(8.2 * stepProgress).toFixed(1)} of 8.2 MB`)
    : i === 1 ? (current >= 1 ? `${rows.toLocaleString("en-US")} of ${ROWS.toLocaleString("en-US")} rows` : undefined)
    : i === 2 ? (current > 2 ? "14 columns matched" : undefined)
    : i === 3 ? (current > 3 ? "12,431 imported · 49 skipped" : current === 3 ? `${Math.round(12431 * stepProgress).toLocaleString("en-US")} imported` : undefined)
    : current > 4 ? "Ready" : undefined;

  const card = "w-full rounded-3xl bg-background p-5 shadow-[inset_0_0_0_1px_var(--border)]";
  const all = show === "all";

  return (
    <div className="flex min-h-screen w-full items-center justify-center px-4 py-8">
      <div className={all ? "grid w-full max-w-[760px] gap-3 sm:grid-cols-2" : "w-full max-w-[420px]"}>
        {(all || show === "bar") && (
          <div className={card}>
            <Progress
              {...props}
              thickness={thickness}
              label="Exporting launch-film.mp4"
              value={indeterminate ? null : exportPct}
              detail={indeterminate ? "Preparing export…" : exportPct >= 100 ? `${FILE_MB} MB · Saved to Downloads` : `${Math.round(sent)} MB of ${FILE_MB} MB · ${left}s left`}
            />
          </div>
        )}
        {(all || show === "ring") && (
          <div className={`${card} flex items-center justify-center ${all ? "sm:row-span-2" : ""}`}>
            <Progress {...props} variant="ring" thickness={thickness + 2} size={all ? 148 : 168} value={ring} label="Move goal" detail={`${Math.round((ring / 100) * 620)} of 620 kcal`} />
          </div>
        )}
        {(all || show === "segments") && (
          <div className={card}>
            <Progress {...props} variant="segments" thickness={thickness + 4} label="iCloud storage" max={200} segments={storage} format={(n) => `${n.toFixed(1)} GB`} />
          </div>
        )}
        {(all || show === "steps") && (
          <div className={`${card} ${all ? "sm:col-span-2" : ""}`}>
            <Progress
              {...props}
              variant="steps"
              label="Importing customers"
              steps={STEPS.map((label, i) => ({ label, detail: detail(i) }))}
              current={current}
              stepProgress={stepProgress}
            />
          </div>
        )}
      </div>
    </div>
  );
}

Dependencies

More by Malay Patel

View all
  • Halftone

    Halftone

    48
  • Balloon Button

    Balloon Button

    33
  • Fold Toolbar

    Fold Toolbar

    31
  • Hold To Confirm

    Hold To Confirm

    14
  • Marquee

    Marquee

    9
  • Aurora

    Aurora

    6
  • Otp Input

    Otp Input

    5
  • Copy Button

    Copy Button

    4