Controlsradix-ui
Progress
A capsule bar filling from the second chart colour into the accent.
Installation
pnpm dlx shadcn@latest add https://glasscn.app/r/progress.jsonReact Native (iOS, Android and web through react-native-web) — same parts and props:
pnpm dlx shadcn@latest add https://glasscn.app/r/native-progress.jsonOr with the namespace set up: shadcn add @glasscn-app/progress
Source
components/glass/progress.tsx
"use client"
import * as React from "react"
import { cn } from "@/lib/glass-cn"
import { Progress as ProgressPrimitive } from "radix-ui"
/**
* A capsule bar whose fill runs from the second chart colour into the accent. `value` runs from 0 to `max` (100).
* The fill is sized by `width`, so it grows from the inline start and runs right-to-left under `dir="rtl"`.
*/
function Progress({ className, value, max = 100, ...props }: React.ComponentProps<typeof ProgressPrimitive.Root>) {
const pct = max > 0 ? Math.min(100, Math.max(0, ((value || 0) / max) * 100)) : 0
return (
<ProgressPrimitive.Root
data-slot="progress"
value={value}
max={max}
className={cn("relative h-2.5 w-full overflow-hidden rounded-button bg-fill", className)}
{...props}
>
<ProgressPrimitive.Indicator
data-slot="progress-indicator"
data-glass-motion
className="h-full rounded-button bg-linear-to-r from-chart-2 to-primary transition-[width] duration-[calc(var(--glass-duration)*3)] ease-out motion-reduce:transition-none rtl:bg-linear-to-l"
style={{ width: `${pct}%` }}
/>
</ProgressPrimitive.Root>
)
}
export { Progress }