Skip to content
Primitives

Progress

Progress bar that fills on scroll-into-view, with an optional striped indicator.

Motionwidth fill on tween.draw via whileInView

Install

Install Kineto and follow the theme setup once in your app.

bash
npm install kineto
tsx
import { Progress } from "kineto/progress";

Preview

Completed51%
Running32%
tsx
"use client";

import * as React from "react";
import { motion, useReducedMotion } from "motion/react";

import { cn } from "@/lib/cn";
import { tween, viewportOnce } from "@/lib/motion-presets";

export interface ProgressProps extends React.HTMLAttributes<HTMLDivElement> {
  /** 0–100. */
  value?: number;
  /** Class applied to the filled indicator (e.g. a status color). */
  indicatorClassName?: string;
  /** Add a diagonal striped texture to the indicator. */
  striped?: boolean;
}

const Progress = React.forwardRef<HTMLDivElement, ProgressProps>(
  ({ className, value = 0, indicatorClassName, striped = false, ...props }, ref) => {
    const reduced = useReducedMotion();
    const clamped = Math.min(100, Math.max(0, value));

    return (
      <div
        ref={ref}
        role="progressbar"
        aria-valuenow={clamped}
        aria-valuemin={0}
        aria-valuemax={100}
        className={cn(
          "relative h-2 w-full overflow-hidden rounded-full bg-muted",
          className
        )}
        {...props}
      >
        <motion.div
          className={cn(
            "h-full rounded-full bg-primary",
            striped &&
              "bg-[repeating-linear-gradient(45deg,hsl(var(--primary)),hsl(var(--primary))_8px,hsl(var(--primary)/0.7)_8px,hsl(var(--primary)/0.7)_16px)]",
            indicatorClassName
          )}
          initial={{ width: 0 }}
          whileInView={{ width: `${clamped}%` }}
          viewport={viewportOnce}
          transition={reduced ? { duration: 0 } : tween.draw}
        />
      </div>
    );
  }
);
Progress.displayName = "Progress";

export { Progress };

src/components/ui/progress.tsx

Props

PropTypeDefaultDescription
valuenumber00–100.
stripedbooleanfalseAdd a diagonal striped texture.
indicatorClassNamestring—Class for the filled bar (e.g. a status color).