Progress

A bar that shows how far a task has got, its fill sliding to each new value.

import { Progress } from "@produkto/ui/Progress";
import { useEffect, useState } from "react";

const Example = () => {
  const [progress, setProgress] = useState(13);

  useEffect(() => {
    const timer = setTimeout(() => setProgress(66), 500);
    return () => clearTimeout(timer);
  }, []);

  return (
    <Progress aria-label="Label" className="w-full max-w-sm" value={progress} />
  );
};

export default Example;

Usage

import { Progress } from "@produkto/ui/Progress";
<Progress aria-label="Label" value={33} />

Examples

Sizes

size sets the track's thickness: sm 4px, base 8px (the default) or lg 12px, and the dots of segments follow.

import { Label } from "@produkto/ui/Label";
import { Progress, type ProgressSize } from "@produkto/ui/Progress";

const variants: { size: ProgressSize; label: string }[] = [
  { size: "sm", label: "Small" },
  { size: "base", label: "Base" },
  { size: "lg", label: "Large" },
];

const Example = () => (
  <div className="flex w-full max-w-sm flex-col gap-4">
    {variants.map((variant) => (
      <div className="flex flex-col gap-2" key={variant.size}>
        <Label id={`progress-size-${variant.size}`}>{variant.label}</Label>
        <Progress
          aria-labelledby={`progress-size-${variant.size}`}
          size={variant.size}
        />
      </div>
    ))}
  </div>
);

export default Example;

Border radius

borderRadius sets the corners of the track, and of the dots of segments, on the kit's one scale: none, xs 4px, sm 6px, base 8px, lg 12px, xl 16px, or full, the default; no corner rounds past half the track's height.

import { Label } from "@produkto/ui/Label";
import {
  Progress,
  type ProgressBorderRadius,
} from "@produkto/ui/Progress";

const variants: { borderRadius: ProgressBorderRadius; label: string }[] = [
  { borderRadius: "none", label: "None" },
  { borderRadius: "xs", label: "xs" },
  { borderRadius: "sm", label: "sm" },
  { borderRadius: "base", label: "base" },
  { borderRadius: "lg", label: "lg" },
  { borderRadius: "xl", label: "xl" },
  { borderRadius: "full", label: "full" },
];

const Example = () => (
  <div className="flex w-full max-w-sm flex-col gap-4">
    {variants.map((variant) => (
      <div className="flex flex-col gap-2" key={variant.borderRadius}>
        <Label id={`progress-radius-${variant.borderRadius}`}>
          {variant.label}
        </Label>
        <Progress
          aria-labelledby={`progress-radius-${variant.borderRadius}`}
          borderRadius={variant.borderRadius}
        />
      </div>
    ))}
  </div>
);

export default Example;

Indeterminate

Without a value, as by default, a bar sweeps across the track while there is no telling how long the task will take.

import { Progress } from "@produkto/ui/Progress";

const Example = () => (
  <Progress aria-label="Label" className="w-full max-w-sm" />
);

export default Example;

Max

max is the value that fills the bar, 100 by default: here 50 of 100 beside 50 of 200.

import { Progress } from "@produkto/ui/Progress";

const Example = () => (
  <div className="flex w-full max-w-sm flex-col gap-4">
    <Progress aria-label="Label" value={50} />
    <Progress aria-label="Label" max={200} value={50} />
  </div>
);

export default Example;

Segments

segments draws that many steps instead of a bar: a short line for each step reached, up to value, and a dot for each step still ahead, for the steps of a flow: here step two of three.

import { Progress } from "@produkto/ui/Progress";

const Example = () => <Progress aria-label="Label" segments={3} value={2} />;

export default Example;

API Reference

Progress

ProgressProps · components/Progress/Progress.types.ts
PropTypeDefault
sizeProgressSize"sm" | "base" | "lg""base"
borderRadiusProgressBorderRadius"none" | "xs" | "sm" | "base" | "lg" | "xl" | "full""full"
segmentsnumber-
value-null
maxnumber100

It also takes the props of Radix Progress.Root.