Progress not working

Hey, I am using the Progress component from shadcn/ui and setting a max value, but the progress bar doesn't care. it still stays on a 100 point scale. I've tried rendering on both server and client, and tried hard coding the component. still doesn't work. Anyone else have this problem?
No description
No description
1 Reply
1916Eco
1916Eco12mo ago
The progress bar for somereason doesnt take a max val even though the types are defined for it if you go to where the progress.tsx is most likely components/ui/progress.tsx you can make a slight change that worked for me.
const Progress = React.forwardRef<
React.ElementRef<typeof ProgressPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>
>(({ className, value, max, ...props }, ref) => (
<ProgressPrimitive.Root
ref={ref}
className={cn(
"relative h-4 w-full overflow-hidden rounded-full bg-secondary",
className,
)}
{...props}
>
<ProgressPrimitive.Indicator
className="h-full w-full flex-1 bg-primary transition-all"
style={{ transform: `translateX(-${(max || 100) - (value || 0)}%)` }}
/>
</ProgressPrimitive.Root>
));
Progress.displayName = ProgressPrimitive.Root.displayName;

export { Progress };
const Progress = React.forwardRef<
React.ElementRef<typeof ProgressPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>
>(({ className, value, max, ...props }, ref) => (
<ProgressPrimitive.Root
ref={ref}
className={cn(
"relative h-4 w-full overflow-hidden rounded-full bg-secondary",
className,
)}
{...props}
>
<ProgressPrimitive.Indicator
className="h-full w-full flex-1 bg-primary transition-all"
style={{ transform: `translateX(-${(max || 100) - (value || 0)}%)` }}
/>
</ProgressPrimitive.Root>
));
Progress.displayName = ProgressPrimitive.Root.displayName;

export { Progress };
this is the main part of the code I only changed max being passed through with className, value... and in the style I added (max || 100)
Want results from more Discord servers?
Add your server