# Progress

A bar and a ring on ui-sdk's Progress. The fill shifts hue from light at its tail to deep at its leading edge, so the edge is always the richest colour, on a 20% tint of the tone. A complete ring turns to a diagonal light-to-deep gradient, with a check in the success tone.

- Beta: ready to use; its API can still change in a minor release.
- Category: Status & indicators

```tsx
import { Progress, ProgressRing } from "@leap-crm/design-system";
```

## Best practices

- Do: Name every bar and ring with `aria-label`, like "Intake completed". A bare percentage means nothing out of context.
- Do: Use `ProgressRing` when a count reads better than a bar, and pass it as children, like "3/5" intake questions. Use 32 or 48 in rows and cards, and 100 only as a page's hero.
- Do: Set `tone="orange"` while the next step waits on someone else, like a client signing a costs agreement, and `success` once it is done.
- Don't: Use it for work with no known end, like a save or a search. Use `Spinner`, so the bar never sits at a made-up value.
- Don't: Let the tone be the only sign of done or waiting. Say it in the text beside the bar too.

## Related

- [Spinner](./spinner.md)
- [Skeleton](./skeleton.md)
- [Pipeline](./pipeline.md)

## Examples

What the examples import:

```tsx
import { useState } from "react";
import { Button, Progress, ProgressRing, type ProgressTone } from "@leap-crm/design-system";
```

Scaffolding the examples call. It lives in the docs page, not in the library:

```tsx
const tones: ProgressTone[] = ["navy", "orange", "success"];

function Stepper() {
  const [value, setValue] = useState(40);
  return (
    <div className="flex flex-col gap-4">
      <div className="flex items-center gap-4">
        <ProgressRing value={value} aria-label="Intake completed" />
        <Progress
          value={value}
          aria-label="Intake completed"
          className="w-60"
        />
      </div>
      <div className="flex gap-2">
        <Button
          size="sm"
          intent="outline"
          onClick={() => setValue(v => Math.max(0, v - 20))}
        >
          Back
        </Button>
        <Button
          size="sm"
          intent="outline"
          onClick={() => setValue(v => Math.min(100, v + 20))}
        >
          Next step
        </Button>
      </div>
    </div>
  );
}
```

### Bar

4 px, navy for progress, orange for waiting on someone, success once done.

```tsx
<div className="flex w-60 flex-col gap-4">
  {tones.map(tone => (
    <Progress
      key={tone}
      tone={tone}
      value={tone === "success" ? 100 : 60}
      aria-label={`${tone} progress`}
    />
  ))}
</div>
```

### Ring

32 and 48 in rows and cards, 100 as a page's hero.

```tsx
<div className="flex flex-col gap-4">
  {([32, 48, 100] as const).map(size => (
    <div key={size} className="flex items-center gap-6">
      {tones.map(tone => (
        <ProgressRing
          key={tone}
          tone={tone}
          size={size}
          value={tone === "success" ? 100 : 60}
          aria-label={`${tone} progress`}
        >
          {tone !== "success" && size !== 100 ? "3/5" : undefined}
        </ProgressRing>
      ))}
    </div>
  ))}
</div>
```

### Moving

The fill and the arc ease to a new value.

```tsx
<Stepper />
```

## Props

### Progress

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` (required) | `number` |  | Between 0 and max. |
| `max` | `number` | `100` | The value that means done. 100 by default. |
| `tone` | `"navy" \| "orange" \| "success"` | `"navy"` | Navy for progress, orange for something waiting on someone, success once done. |
| `aria-label` (required) | `string` |  | Names the bar for screen readers, like "Intake completed". Required: a bare percentage means nothing out of context. |
| `className` | `string` |  | Classes added to the root element, merged with its own. Tokens only. |

### ProgressRing

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` (required) | `number` |  | Between 0 and max. |
| `max` | `number` | `100` | The value that means done. 100 by default. |
| `tone` | `"navy" \| "orange" \| "success"` | `"navy"` | navy for progress, orange for something waiting on someone, success when done. |
| `size` | `32 \| 48 \| 100` | `48` | 32 and 48 in rows and cards, 100 as a page's hero. |
| `children` | `ReactNode` |  | What sits in the middle, like "3/5". The percentage by default; a check once complete in the success tone. |
| `aria-label` (required) | `string` |  | Names the ring for screen readers, like "Intake questions answered". Required: a bare percentage means nothing out of context. |
| `className` | `string` |  | Classes added to the root element, merged with its own. Tokens only. |
