# Progress

A rounded tube that fills with a springy ease and rolling stripes. It glints when full.

Docs: https://cozy-ui.solo.engineer/docs/components/progress/

Install: `npx shadcn@latest add @cozy/progress`

### Usage

```tsx
import { Progress } from "@/components/ui/progress"

<Progress value={64} tone="success" />
```

### Props

| Prop | Type | Default | Description |
|---|---|---|---|
| value | `number` | – | Current value, 0 to max. |
| tone | `"reward" \| "success" \| "primary"` | `"reward"` | Fill colour. |
| size | `"default" \| "sm"` | `"default"` | Small is 14 px tall. |

### Example

```tsx
import { useEffect, useState } from "react";
import { Progress } from "@/components/ui/progress";

export default function ProgressDemo() {
  const [value, setValue] = useState(18);
  useEffect(() => {
    const id = setInterval(() => setValue((v) => (v >= 100 ? 12 : Math.min(100, v + 22))), 1200);
    return () => clearInterval(id);
  }, []);
  return (
    <div className="grid w-full max-w-sm gap-1">
      <span className="text-sm">Experience · {value}%</span>
      <Progress value={value} aria-label="Experience" />
    </div>
  );
}
```

### Source (components/ui/progress.tsx)

```tsx
import * as React from "react";
import { Progress as ProgressPrimitive } from "radix-ui";
import { cn } from "@/lib/utils";

type ProgressProps = React.ComponentProps<typeof ProgressPrimitive.Root> & {
  tone?: "reward" | "success" | "primary";
  size?: "default" | "sm";
};

function Progress({ className, value, max = 100, tone = "reward", size = "default", ...props }: ProgressProps) {
  const pct = Math.min(100, Math.max(0, ((value ?? 0) / max) * 100));
  return (
    <ProgressPrimitive.Root
      data-slot="progress"
      data-complete={pct >= 100 || undefined}
      value={value == null ? value : Math.min(max, Math.max(0, value))}
      max={max}
      className={cn("cz-progress", tone !== "reward" && `cz-progress--${tone}`, size === "sm" && "cz-progress--sm", className)}
      {...props}
    >
      <ProgressPrimitive.Indicator data-slot="progress-indicator" className="cz-progress__fill" style={{ transform: `translateX(-${100 - pct}%)` }} />
    </ProgressPrimitive.Root>
  );
}

export { Progress };
```

npm: `import { Progress } from "@0xtrou/cozy-ui"` (after `npm install @0xtrou/cozy-ui` and `import "@0xtrou/cozy-ui/styles.css"`).
