# Progress

shadcn progress drawn as segmented blocks.

Source: https://www.ui95.dev/ui/progress

## Examples

```tsx
import { useEffect, useState } from "react"

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

import type { ShowcaseDemo } from "../types"

const VALUES = [0, 25, 50, 75, 100] as const

const LIVE_STEP = 5

const LIVE_INTERVAL_MS = 400

function LiveProgress() {
  const [value, setValue] = useState(0)

  useEffect(() => {
    const interval = window.setInterval(
      () => setValue((current) => (current >= 100 ? 0 : current + LIVE_STEP)),
      LIVE_INTERVAL_MS
    )
    return () => window.clearInterval(interval)
  }, [])

  return <Progress value={value} aria-label="Live progress" />
}

export const demo: ShowcaseDemo = {
  span: "single",
  variants: [
    ...VALUES.map((value) => ({
      label: `${value}%`,
      render: () => <Progress value={value} aria-label={`${value} percent`} />,
    })),
    { label: "live", render: () => <LiveProgress /> },
  ],
}
```

## Installation

```bash
npx shadcn@latest add https://www.ui95.dev/r/progress.json
```

Run it in a Radix shadcn project that already has the UI95 theme.

Dependencies:

```bash
npm install cn radix-ui
```

`components/ui/progress.tsx`

```tsx
"use client"

import { cn } from "cn"
import { Progress as ProgressPrimitive } from "radix-ui"
import * as React from "react"


function Progress({
  className,
  value,
  ...props
}: React.ComponentProps<typeof ProgressPrimitive.Root>) {
  const percent = Math.min(100, Math.max(0, value ?? 0))

  return (
    <ProgressPrimitive.Root
      data-slot="progress"
      value={value}
      className={cn(
        "relative flex h-7 w-full items-center overflow-hidden pixel-border border-border well p-(--pixel)",
        className
      )}
      {...props}
    >
      <ProgressPrimitive.Indicator
        data-slot="progress-indicator"
        className="h-full bg-well-fill segments"
        style={{ width: `${percent}%` }}
      />
    </ProgressPrimitive.Root>
  )
}

export { Progress }
```

## API reference

### Progress

No props of its own. It forwards the props of the element or primitive it wraps.
