# Progress

Shows how far along something is, like an upload or a setup.

```tsx
import { ProgressBar, ProgressCircle } from '@halo-ds/react';
```

## When to use it
Use progress when you can measure how much is done. Progress bar is a track that fills from the left; Progress circle fills a ring; Progress field adds a label, the percentage and a hint. Use Indeterminate, or a Spinner, when you can't measure it.

## Do
- Show the number as well as the bar.
- Say what happened at the end: complete, or failed with a way to retry.
- Move smoothly; don't jump backwards.
- Switch from Indeterminate to Default as soon as you can measure it.

## Don't
- Show progress for tasks that finish in under a second.
- Fake progress that isn't tied to the real task.
- Use colour alone for success or failure; say it in the hint.
- Stack many bars for one task; show one overall bar.

## Progress or Spinner?
Both show that something is happening. Pick by whether you can measure it.
- **Progress**: You know how much is done, like bytes uploaded. Longer tasks, where people want to know how long is left. Amounts, like storage used or a profile filled in.
- **Spinner**: You can't measure it, like waiting for a server. Short waits of a few seconds. Or use Indeterminate when it sits where a bar will be.

## Props
### ProgressBar props
| Prop | Type | What it does |
| --- | --- | --- |
| `value` | `number \| undefined` | How much is done. Leave it out for an indeterminate bar. |
| `max` | `number \| undefined` | The value that counts as complete. |
| `status` | `ProgressStatus \| undefined` | Colour of the fill. Figma: Status. |
| `size` | `"sm" \| "md" \| undefined` | 4px (sm) or 8px (md) tall. Figma: Size. |
| `label` | `ReactNode` | What is in progress, shown above the bar. Figma: Label. |
| `valueLabel` | `ReactNode` | The value shown on the right, like "60%" or "7.2 of 10 GB". Defaults to the percentage; false hides it. Figma: Value. |
| `hint` | `ReactNode` | What is happening or what to do next. Figma: Hint. |
| `classNames` | `Partial<Record<ProgressBarPart, string>> \| undefined` | Extra class names for the parts inside the component, by part name, like `{ header: 'my-header' }`. |
| `styles` | `Partial<Record<ProgressBarPart, CSSProperties>> \| undefined` | Inline styles for the parts inside the component, by part name, like `{ footer: { gap: 4 } }`. |
It also takes the usual HTML attributes for its element.

### ProgressCircle props
| Prop | Type | What it does |
| --- | --- | --- |
| `value` (required) | `number` |  |
| `max` | `number \| undefined` |  |
| `size` | `"sm" \| "md" \| "lg" \| undefined` | 24, 40 or 64px. Figma: Size. |
| `showValue` | `boolean \| undefined` | Shows the percentage in the middle (md and lg). Figma: Label. |
| `aria-label` | `string \| undefined` | Read by screen readers. |
| `classNames` | `Partial<Record<ProgressCirclePart, string>> \| undefined` | Extra class names for the parts inside the component, by part name, like `{ header: 'my-header' }`. |
| `styles` | `Partial<Record<ProgressCirclePart, CSSProperties>> \| undefined` | Inline styles for the parts inside the component, by part name, like `{ footer: { gap: 4 } }`. |
It also takes the usual HTML attributes for its element.

## Examples
### Overview
```tsx
import { ProgressBar, ProgressCircle } from '@halo-ds/react';

export default function Example() {
  return (
    <div style={{ display: 'grid', gap: 24, width: 320, justifyItems: 'start' }}>
      <ProgressBar label="Uploading" value={64} style={{ width: '100%' }} />
      <ProgressBar label="Storage" value={92} status="error" hint="Almost full." style={{ width: '100%' }} />
      <ProgressCircle value={72} />
    </div>
  );
}
```

### Status
Default, success, error, and indeterminate when you do not know how long it takes.
```tsx
import { ProgressBar } from '@halo-ds/react';

export default function Demo() {
  return (
    <div className="demo-stack" style={{ width: 360 }}>
      <ProgressBar value={60} label="Uploading files" hint="3 of 5 files uploaded" />
      <ProgressBar value={100} status="success" label="Uploading files" hint="Upload complete" />
      <ProgressBar value={60} status="error" label="Uploading files" hint="Upload failed. Check your connection." />
      <ProgressBar label="Preparing your export" valueLabel="" hint="This can take a minute." />
    </div>
  );
}
```

### An amount
Show an amount instead of a percentage, like storage used.
```tsx
import { ProgressBar } from '@halo-ds/react';

export default function Demo() {
  return (
    <div style={{ width: 360 }}>
      <ProgressBar value={72} label="Storage" valueLabel="7.2 of 10 GB" hint="Upgrade your plan for more space." />
    </div>
  );
}
```

### Circle
A ring for small or square spaces, in three sizes.
```tsx
import { ProgressCircle } from '@halo-ds/react';

export default function Demo() {
  return (
    <div className="demo-row">
      <ProgressCircle value={25} size="sm" aria-label="Profile complete" />
      <ProgressCircle value={50} size="md" aria-label="Profile complete" />
      <ProgressCircle value={75} size="lg" aria-label="Profile complete" />
    </div>
  );
}
```

More: https://halodesignsystem.dev/components/progress
