Feedback

Progress

Task progress.

Install

Install
npx shadcn@latest add http://localhost:3000/r/progress.json

Usage

progress-example.tsx
"use client"

import { Progress, ProgressLabel } from "@/components/ui/progress"

export function Example() {
  const progress = 68
  return (
    <div className="w-full max-w-xs space-y-2">
      <Progress value={progress} locale="en-US">
        <div className="flex items-center">
          <ProgressLabel>Uploading assets</ProgressLabel>
          <span className="ml-auto text-sm tabular-nums text-muted-foreground">
            {progress}%
          </span>
        </div>
      </Progress>
    </div>
  )
}

API

ProgressProgressTrackProgressIndicatorProgressLabelProgressValue
TypeScript
function Progress(props: ProgressPrimitive.Root.Props)

function ProgressTrack(props: ProgressPrimitive.Track.Props)

function ProgressIndicator(props: ProgressPrimitive.Indicator.Props)

function ProgressLabel(props: ProgressPrimitive.Label.Props)

function ProgressValue(props: ProgressPrimitive.Value.Props)
Source code +
components/ui/progress.tsx
"use client"

import { Progress as ProgressPrimitive } from "@base-ui/react/progress"
import { cn } from "cn"

function Progress({
  className,
  children,
  value,
  ...props
}: ProgressPrimitive.Root.Props) {
  return (
    <ProgressPrimitive.Root
      value={value}
      data-slot="progress"
      className={cn("flex flex-wrap gap-3", className)}
      {...props}
    >
      {children}
      <ProgressTrack>
        <ProgressIndicator />
      </ProgressTrack>
    </ProgressPrimitive.Root>
  )
}

function ProgressTrack({ className, ...props }: ProgressPrimitive.Track.Props) {
  return (
    <ProgressPrimitive.Track
      className={cn(
        "relative flex h-2 w-full items-center overflow-x-hidden rounded-2xl bg-muted",
        className
      )}
      data-slot="progress-track"
      {...props}
    />
  )
}

function ProgressIndicator({
  className,
  ...props
}: ProgressPrimitive.Indicator.Props) {
  return (
    <ProgressPrimitive.Indicator
      data-slot="progress-indicator"
      className={cn("h-full bg-primary transition-all", className)}
      {...props}
    />
  )
}

function ProgressLabel({ className, ...props }: ProgressPrimitive.Label.Props) {
  return (
    <ProgressPrimitive.Label
      className={cn("text-sm font-medium", className)}
      data-slot="progress-label"
      {...props}
    />
  )
}

function ProgressValue({ className, ...props }: ProgressPrimitive.Value.Props) {
  return (
    <ProgressPrimitive.Value
      className={cn(
        "ml-auto text-sm text-muted-foreground tabular-nums",
        className
      )}
      data-slot="progress-value"
      {...props}
    />
  )
}

export {
  Progress,
  ProgressTrack,
  ProgressIndicator,
  ProgressLabel,
  ProgressValue,
}

Registry JSON ↗