# Progress

- **[Atoms](/components/)**

A bar for a task with a known share done, or an indeterminate one while it works.

## When to use

- **Use for**: A task with a known share done, or work with an unknown end.
- **Not for**: A wait under a second. Not a step indicator for a form.
- **Pairs with**: Text, Banner, Button.

## Preview

progress.tsx

```
import { Theme } from '@/components/klarhimmel/theme/style';
import { Progress } from '@/components/klarhimmel/ui/progress';

export default function Example() {
  return (
    <Theme theme="brand">
      <Progress label="Uploading room photos" value={64} showValue />
    </Theme>
  );
}
```

## Import

- **CLI**

  ```
  npx shadcn add @klarhimmel/progress
  ```
- **Import**

  ```
  import { Progress } from '@/components/klarhimmel/ui/progress';
  ```

- **Files**: progress.tsx, in components/klarhimmel/ui/. With it: theme, utils.
- **Render in**: Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.

## Examples

- **States**

  ```
  import { Progress } from '@/components/klarhimmel/ui/progress';
  
  export default function ProgressStates() {
    return (
      <div className="flex w-[min(24rem,calc(100cqw-3rem))] flex-col gap-5">
        <Progress label="Syncing the calendar" showValue />
        <Progress label="Backup" value={0} showValue />
        <Progress label="Import finished" value={100} showValue />
      </div>
    );
  }
  ```
- **Steps**

  ```
  import { useState } from 'react';
  import { Button } from '@/components/klarhimmel/ui/button';
  import { Progress } from '@/components/klarhimmel/ui/progress';
  
  export default function ProgressSteps() {
    const [step, setStep] = useState(2);
    return (
      <div className="flex w-[min(24rem,calc(100cqw-3rem))] flex-col gap-4">
        <Progress label={`Step ${step} of 5`} value={step} max={5} showValue />
        <div className="flex gap-2">
          <Button size="sm" variant="secondary" disabled={step <= 1} onClick={() => setStep((s) => s - 1)}>Back</Button>
          <Button size="sm" disabled={step >= 5} onClick={() => setStep((s) => s + 1)}>Next</Button>
        </div>
      </div>
    );
  }
  ```

## Props

- **label**: Required: what is progressing ("Upload", "Profile completeness").
- **value**: 0 to `max`. Omit for an indeterminate bar: work is happening and the end is unknown.
- **max**: The value that means done.
- **showValue**: Show the label and the percentage above the bar.
- **className**: Extra classes, merged after the component's own.

[Previous](/components/separator)

[Next](/components/alert-dialog)
