35 lines
855 B
TypeScript
35 lines
855 B
TypeScript
import * as React from "react";
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
interface ProgressProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
value?: number;
|
|
}
|
|
|
|
const Progress = React.forwardRef<HTMLDivElement, ProgressProps>(
|
|
({ className, value = 0, ...props }, ref) => {
|
|
return (
|
|
<div
|
|
ref={ref}
|
|
role="progressbar"
|
|
aria-valuemin={0}
|
|
aria-valuemax={100}
|
|
aria-valuenow={value}
|
|
className={cn(
|
|
"relative h-4 w-full overflow-hidden rounded-full bg-primary/20",
|
|
className
|
|
)}
|
|
{...props}
|
|
>
|
|
<div
|
|
className="h-full bg-primary transition-all duration-300 ease-in-out rounded-full"
|
|
style={{ width: `${Math.min(100, Math.max(0, value))}%` }}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
);
|
|
Progress.displayName = "Progress";
|
|
|
|
export { Progress };
|