Installation
Add the component
npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/react/progress.jsonFirst component? Set up your project first
Frameworks
The live preview is React. Each tab below is the file that ships for that framework, with the same durations, springs and reduced-motion rule.
"use client";
import * as React from "react";
import { animate, motion, useReducedMotion } from "motion/react";
import { cn } from "@/lib/utils";
export type ProgressProps = {
value?: number;
max?: number;
label?: string;
showValue?: boolean;
className?: string;
};
const settle = {
type: "spring",
stiffness: 300,
damping: 35,
restDelta: 0.01,
restSpeed: 0.1,
} as const;
const count = { type: "spring", stiffness: 90, damping: 50 } as const;
export function Progress({
value = 0,
max = 100,
label = "Uploading assets",
showValue = true,
className,
}: ProgressProps) {
const reduce = useReducedMotion();
const safeMax = max > 0 ? max : 100;
const clamped = Math.min(safeMax, Math.max(0, value));
const percent = (clamped / safeMax) * 100;
const [shown, setShown] = React.useState(reduce ? clamped : 0);
React.useEffect(() => {
if (reduce) {
setShown(clamped);
return;
}
const controls = animate(shown, clamped, {
...count,
onUpdate: (latest) => setShown(latest),
});
return () => controls.stop();
}, [clamped, reduce]);
return (
<div className={cn("w-full max-w-[380px]", className)}>
<div className="mb-2 flex items-center justify-between text-[13px] text-muted-foreground">
<span>{label}</span>
{showValue && <span className="tabular-nums">{Math.round(shown)}%</span>}
</div>
<div
role="progressbar"
aria-valuemin={0}
aria-valuemax={safeMax}
aria-valuenow={clamped}
className="h-2 w-full overflow-hidden rounded-full bg-accent"
>
<motion.div
initial={false}
animate={{ width: `${percent}%` }}
transition={reduce ? { duration: 0 } : settle}
className="h-full rounded-full bg-foreground"
/>
</div>
</div>
);
}Install
npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/react/progress.jsonDependencies
motion lucide-reactThe registry keeps the component source, its motion tokens and the reduced-motion branch together, so the install never pulls a different animation from the preview.
Usage
Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.
import { Progress } from "@/components/prequelui/progress";
export default function Demo() {
return <Progress value={64} className="w-[360px]" />;
}import { Progress } from "@/components/prequelui/progress";
export function Variant() {
return (
<Progress tempo={1.2}>
…
</Progress>
);
}Animation
The bar never jumps between values. Each new value retargets the same width spring, which is damped just enough to settle without a visible overshoot, even when the value moves backwards.
- Width spring: 300 / 35, restDelta 0.01, restSpeed 0.1.
- Retargeting keeps the current velocity instead of restarting.
- The track colour is static; only the indicator changes width.
- Reduced motion writes the new width immediately.
API Reference
Every part takes exactly the props of the Progress primitive. The animated surface adds only motion props, so the accessibility tree and keyboard behaviour stay the same.
Progress
| Prop | Type | Default |
|---|---|---|
| value | number | 0 |
| max | number | 100 |
| indicatorClassName | string | — |
| transition | Transition | component spring or tween |
| className | string | — |