Progress Tracker
tool-ui/progress-trackerFreeBlock
Show real-time status feedback for multi-step operations in AI interfaces.
See it running
Open the demo on tool-ui
www.tool-ui.com/components/progress-trackerInstall it
npx shadcn@latest add https://www.tool-ui.com/r/progress-tracker.jsonSource
1import { cn } from "./_adapter";2import type {3 ProgressStep,4 ProgressTrackerChoice,5 ProgressTrackerProps,6} from "./schema";7import { Check, X, Loader2, Timer, AlertCircle } from "lucide-react";8import type { LucideIcon } from "lucide-react";910function formatElapsedTime(milliseconds: number): string {11 const roundedSeconds = Math.round(Math.max(0, milliseconds) / 100) / 10;1213 if (roundedSeconds < 60) {14 return `${roundedSeconds.toFixed(1)}s`;15 }1617 const wholeSeconds = Math.floor(roundedSeconds);18 const minutes = Math.floor(wholeSeconds / 60);19 const remainingSeconds = wholeSeconds % 60;20 return `${minutes}m ${remainingSeconds}s`;21}2223function formatElapsedTimeDateTime(milliseconds: number): string {24 const roundedSeconds = Math.round(Math.max(0, milliseconds) / 100) / 10;2526 if (roundedSeconds < 60) {27 return `PT${Number(roundedSeconds.toFixed(1))}S`;28 }2930 const wholeSeconds = Math.floor(roundedSeconds);31 const hours = Math.floor(wholeSeconds / 3600);32 const minutes = Math.floor((wholeSeconds % 3600) / 60);33 const seconds = wholeSeconds % 60;3435 const hourPart = hours > 0 ? `${hours}H` : "";36 const minutePart = minutes > 0 ? `${minutes}M` : "";37 const secondPart = seconds > 0 ? `${seconds}S` : "";3839 if (!hourPart && !minutePart && !secondPart) {40 return "PT0S";41 }4243 return `PT${hourPart}${minutePart}${secondPart}`;44}4546function getCurrentStepId(steps: ProgressStep[]): string | null {47 const inProgressStep = steps.find((s) => s.status === "in-progress");48 if (inProgressStep) return inProgressStep.id;4950 const failedStep = steps.find((s) => s.status === "failed");51 if (failedStep) return failedStep.id;5253 const firstPendingStep = steps.find((s) => s.status === "pending");54 if (firstPendingStep) return firstPendingStep.id;5556 return null;57}5859function getReceiptState(outcome: ProgressTrackerChoice["outcome"]): {60 toneClassName: string;61 icon: LucideIcon;62} {63 switch (outcome) {64 case "success":65 return {66 toneClassName: "text-emerald-600 dark:text-emerald-500",67 icon: Check,68 };69 case "partial":70 return {71 toneClassName: "text-amber-600 dark:text-amber-500",72 icon: AlertCircle,73 };74 case "failed":75 return {76 toneClassName: "text-destructive",77 icon: AlertCircle,78 };79 case "cancelled":80 return {81 toneClassName: "text-muted-foreground",82 icon: X,83 };84 }85}8687interface StepIndicatorProps {88// … truncated
What it pulls in
npm packages
Files it writes
More from tool-ui
All 27 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Approval Cardapproval-card | tool-ui | Blocks | Free | 2 deps · 11 files | |
| Audioaudio | tool-ui | Blocks | Free | 2 deps · 9 files | |
| Chartchart | tool-ui | Blocks | Free | 2 deps · 8 files | |
| Citationcitation | tool-ui | Blocks | Free | 2 deps · 15 files | |
| Code Blockcode-block | tool-ui | Blocks | Free | 3 deps · 11 files | |
| Code Diffcode-diff | tool-ui | Blocks | Free | 3 deps · 10 files | |
| Data Tabledata-table | tool-ui | Blocks | Free | 1 dep · 17 files | |
| Geo Mapgeo-map | tool-ui | Blocks | Free | 4 deps · 12 files |
