Progress

Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.

Progress Bar
x
x
x
x
x
With Label
Upload progress
x
Controlled
x
File Upload List
document.pdf
x
2m 30s
presentation.pptx
x
45s
spreadsheet.xlsx
x
5m 12s
image.jpg
x
Complete

Installation

Install the dependencies

pnpm add cn class-variance-authority github:sveltery/base

Copy the component

Copy the following files into src/lib/components/ui/progress.

src/lib/components/ui/progress/Progress.svelte
<script lang="ts">
  import { Progress as Primitive } from '@sveltery/base/progress';
  import { cn } from 'cn';
  import ProgressTrack from './ProgressTrack.svelte';
  import ProgressIndicator from './ProgressIndicator.svelte';
  import type { ProgressProps } from './types.js';
  let { children, class: classProp, value, ...props }: ProgressProps = $props();
</script>
<Primitive.Root {value} data-slot="progress" {...props} class={cn('flex flex-wrap gap-3', classProp)}>
  {@render children?.()}
  <ProgressTrack>
    <ProgressIndicator />
  </ProgressTrack>
</Primitive.Root>
src/lib/components/ui/progress/ProgressIndicator.svelte
<script lang="ts">
  import { Progress as Primitive } from '@sveltery/base/progress';
  import { cn } from 'cn';
  import type { ProgressIndicatorProps } from './types.js';
  let { children, class: classProp, ...props }: ProgressIndicatorProps = $props();
</script>
<Primitive.Indicator data-slot="progress-indicator" {children} {...props} class={cn('bg-primary h-full transition-all', classProp)} />
src/lib/components/ui/progress/ProgressLabel.svelte
<script lang="ts">
  import { Progress as Primitive } from '@sveltery/base/progress';
  import { cn } from 'cn';
  import type { ProgressLabelProps } from './types.js';
  let { children, class: classProp, ...props }: ProgressLabelProps = $props();
</script>
<Primitive.Label data-slot="progress-label" {children} {...props} class={cn('text-sm font-medium', classProp)} />
src/lib/components/ui/progress/ProgressTrack.svelte
<script lang="ts">
  import { Progress as Primitive } from '@sveltery/base/progress';
  import { cn } from 'cn';
  import type { ProgressTrackProps } from './types.js';
  let { children, class: classProp, ...props }: ProgressTrackProps = $props();
</script>
<Primitive.Track data-slot="progress-track" {children} {...props} class={cn('bg-muted h-1 rounded-full relative flex w-full items-center overflow-x-hidden', classProp)} />
src/lib/components/ui/progress/ProgressValue.svelte
<script lang="ts">
  import { Progress as Primitive } from '@sveltery/base/progress';
  import { cn } from 'cn';
  import type { ProgressValueProps } from './types.js';
  let { children, class: classProp, ...props }: ProgressValueProps = $props();
</script>
<Primitive.Value data-slot="progress-value" {children} {...props} class={cn('text-muted-foreground ml-auto text-sm tabular-nums', classProp)} />
src/lib/components/ui/progress/types.ts
export type {
  ProgressRootProps as ProgressProps,
  ProgressTrackProps,
  ProgressIndicatorProps,
  ProgressLabelProps,
  ProgressValueProps,
  ProgressState,
  ProgressStatus,
} from '@sveltery/base/progress';
src/lib/components/ui/progress/index.ts
export { default as Progress } from './Progress.svelte';
export { default as ProgressTrack } from './ProgressTrack.svelte';
export { default as ProgressIndicator } from './ProgressIndicator.svelte';
export { default as ProgressLabel } from './ProgressLabel.svelte';
export { default as ProgressValue } from './ProgressValue.svelte';
export type { ProgressProps, ProgressTrackProps, ProgressIndicatorProps, ProgressLabelProps, ProgressValueProps, ProgressState, ProgressStatus } from './types.js';

Update the import paths

Change the imports to match your project setup.

Usage

<script lang="ts">
  import { Progress, ProgressLabel, ProgressValue } from '$lib/components/ui/progress';
</script>
<Progress value={56}>
  <ProgressLabel>Upload progress</ProgressLabel>
  <ProgressValue />
</Progress>

API reference

Progress is styled on top of the Sveltery Base Progress primitive, which reports the value to assistive technology. Progress renders the track and indicator after its children, so pass ProgressLabel and ProgressValue as children. value is a plain prop: pass a number, or null for an indeterminate bar. See the Base UI Progress documentation for the behavior it ports.