---
title: Progress for Astro
description: "Astro progress tracks for a known value or an unknown completion time."
seo:
    title: Progress for Astro | Shadcn & Tailwind CSS
related:
    - /components/meter
    - /components/spinner
sidebar:
    label: "Progress"
---

```astro
---
import {
  Progress,
  ProgressLabel,
  ProgressValue,
  ProgressTrack,
  ProgressIndicator,
} from "@/components/ui/progress"
---

<div class="grid w-full max-w-sm gap-6">
  <Progress value={65} aria-labelledby="export-label">
    <div class="flex justify-between">
      <ProgressLabel id="export-label">Files exported</ProgressLabel>
      <ProgressValue>65%</ProgressValue>
    </div>
    <ProgressTrack>
      <ProgressIndicator />
    </ProgressTrack>
  </Progress>
  <Progress aria-label="Preparing the export" />
  <Progress value={100} aria-label="Previous export complete" />
</div>
```

## Installation

### Command

```sh
bunx --bun shadcn@latest add @gnostic/progress
```

### Manual

Complete the [Installation guide](/docs/installation) first. Then copy the component files below.

No extra packages are required.

#### src/components/ui/progress/progress.astro

```astro
---
import type { HTMLAttributes } from "astro/types"
import { cn } from "cn"
import Track from "./progress-track.astro"
import Indicator from "./progress-indicator.astro"
type Props = HTMLAttributes<"div"> & {
  value?: number | null
  min?: number
  max?: number
}
const {
  class: className,
  value = null,
  min = 0,
  max = 100,
  style,
  ...props
} = Astro.props
if (
  !Number.isFinite(min) ||
  !Number.isFinite(max) ||
  max <= min ||
  (value !== null && !Number.isFinite(value))
)
  throw new RangeError(
    "Progress needs finite bounds with max greater than min, and a finite value.",
  )
const current = value === null ? null : Math.min(max, Math.max(min, value))
const percent = current === null ? 0 : ((current - min) / (max - min)) * 100
const mergedStyle =
  typeof style === "string"
    ? `${style};--progress-percentage:${percent}%`
    : { ...style, "--progress-percentage": percent + "%" }
---

<div
  data-slot="progress"
  data-indeterminate={current === null ? "" : undefined}
  role="progressbar"
  aria-valuemin={min}
  aria-valuemax={max}
  aria-valuenow={current ?? undefined}
  style={mergedStyle}
  class={cn("flex w-full flex-col gap-2", className)}
  {...props}
>
  <slot>
    <Track>
      <Indicator />
    </Track>
  </slot>
</div>
```

#### src/components/ui/progress/progress-value.astro

```astro
---
import type { HTMLAttributes } from "astro/types"
import { cn } from "cn"
type Props = HTMLAttributes<"span">
const { class: className, ...props } = Astro.props
---

<span
  data-slot="progress-value"
  class={cn("text-sm tabular-nums", className)}
  {...props}
>
  <slot />
</span>
```

#### src/components/ui/progress/progress-indicator.astro

```astro
---
import type { HTMLAttributes } from "astro/types"
import { cn } from "cn"
type Props = HTMLAttributes<"div">
const { class: className, ...props } = Astro.props
---

<div
  data-slot="progress-indicator"
  class={cn(
    "h-full w-(--progress-percentage) bg-primary transition-[width] duration-500 motion-reduce:transition-none in-data-indeterminate:w-1/3 in-data-indeterminate:animate-pulse motion-reduce:in-data-indeterminate:animate-none",
    className,
  )}
  {...props}
></div>
```

#### src/components/ui/progress/progress-track.astro

```astro
---
import type { HTMLAttributes } from "astro/types"
import { cn } from "cn"
type Props = HTMLAttributes<"div">
const { class: className, ...props } = Astro.props
---

<div
  data-slot="progress-track"
  class={cn(
    "block h-1.5 w-full overflow-hidden rounded-full bg-input",
    className,
  )}
  {...props}
>
  <slot />
</div>
```

#### src/components/ui/progress/progress-label.astro

```astro
---
import type { HTMLAttributes } from "astro/types"
import { cn } from "cn"
type Props = HTMLAttributes<"span">
const { class: className, ...props } = Astro.props
---

<span
  data-slot="progress-label"
  class={cn("font-medium text-sm", className)}
  {...props}
>
  <slot />
</span>
```

#### src/components/ui/progress/index.ts

```ts
export { default as Progress } from './progress.astro'
export { default as ProgressLabel } from './progress-label.astro'
export { default as ProgressTrack } from './progress-track.astro'
export { default as ProgressIndicator } from './progress-indicator.astro'
export { default as ProgressValue } from './progress-value.astro'
```

Component classes use the preset configured during project setup. Select the same preset in the docs before copying Manual source. To change installed component classes, edit or reinstall their source. See [Theming](/docs/theming) for details.


## Usage

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

Use the Code tab above for the complete Astro composition.

## API reference

Read the [registry source](/ui/r/progress.json) for the exported parts and prop types.

## When to use Progress

Pass a value between min and max for measured progress. Omit value or pass null for an indeterminate task. The root supplies a default track and indicator; use the exported parts when you need a custom label layout.

## Keyboard and behavior

Give the root `aria-label` or connect it to visible text with `aria-labelledby`. Values are clamped to the range, and indeterminate progress omits `aria-valuenow`. The component renders the initial value; live updates must keep the ARIA value and `--progress-percentage` in step.

## Theme and layout

The indicator uses the primary token and the track uses input color. A reduced-motion preference removes its animation. Never invent a percentage when the task cannot report progress.
