progress.tsx 791 B

12345678910111213141516171819202122232425262728
  1. "use client"
  2. import * as React from "react"
  3. import * as ProgressPrimitive from "@radix-ui/react-progress"
  4. import { cn } from "@/lib/utils"
  5. const Progress = React.forwardRef<
  6. React.ElementRef<typeof ProgressPrimitive.Root>,
  7. React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>
  8. >(({ className, value, ...props }, ref) => (
  9. <ProgressPrimitive.Root
  10. ref={ref}
  11. className={cn(
  12. "relative h-4 w-full overflow-hidden rounded-full bg-secondary",
  13. className
  14. )}
  15. {...props}
  16. >
  17. <ProgressPrimitive.Indicator
  18. className="h-full w-full flex-1 bg-primary transition-all"
  19. style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
  20. />
  21. </ProgressPrimitive.Root>
  22. ))
  23. Progress.displayName = ProgressPrimitive.Root.displayName
  24. export { Progress }