Progress

How far along something is, with a dithered edge on the fill.

brand-assets.zipStarting…
0%
Preparing your exportGathering frames, this can take a moment
Design libraryAcme Studio · 128 components
Syncing
0%synced
Files
0 / 128
Speed
—
Time left
—
Waiting to start…
Step 1 of 4

Name your workspace

It's what your team will see when they join. You can change it later.

Small32%
Default58%
Large84%

Installation

Terminal
npx shadcn@latest add https://fabrickit.org/r/progress.json

This copies the component into components/fabricui and its engine into lib/fabricui. It's your code from then on. First time? Add the theme once: see Installation.

Code

components/fabricui/progress.tsx
"use client";

import * as React from "react";
import { mount } from "@/lib/fabricui/mount";
import { Progress as Engine } from "@/lib/fabricui/progress-engine";
import "./progress.css";

const useIsoLayoutEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
const cx = (...c: (string | false | undefined)[]) => c.filter(Boolean).join(" ");

type Drawn = { set: (v: number, o?: { instant?: boolean }) => unknown; indeterminate: (on: boolean) => unknown; destroy: () => void };

/** What a ref gives you: set the value from code (instant skips the glide), or switch to indeterminate. */
export type ProgressHandle = {
  set: (value: number, options?: { instant?: boolean }) => void;
  indeterminate: (on: boolean) => void;
components/fabricui/progress.css
/*
 * Progress — how far along something is. Shared by every page that waits.
 *
 * The library's dither does the work (progress.js draws it): the fill's
 * leading edge dissolves into 2px Bayer dots instead of ending in a hard
 * line, and it closes up solid as it completes; a progress without a known
 * end is a dithered band sweeping along the track. No wobble or overshoot:
 * a progress bar must never show more than has happened.
 *
 *   <div class="progress" role="progressbar" aria-label="Upload" data-value="40"></div>
 *   <div class="progress" role="progressbar" aria-label="Export" data-indeterminate></div>
 *   <div class="progress-ring" role="progressbar" aria-label="Sync" data-value="40" style="--s:72px">
 *     <span class="progress-ring__label">40%</span>
 *   </div>
 *   <div class="progress-steps" role="progressbar" aria-label="Setup" data-steps="4" data-value="1"></div>
 *
lib/fabricui/progress-engine.js
/*
 * progress-engine.js — draws every .progress, .progress-ring and .progress-steps
 * (see progress.css). From progress.js.
 *
 * Each one is a canvas. The value moves on a critically damped spring (it
 * glides to where it's told and never past it), and the fill's leading edge
 * is a dithered fade: 2px dots through the same 4×4 Bayer matrix as the
 * cloth, thinning out toward the value, so the edge looks like it's still
 * being woven. Near 100% the fade closes up and the fill finishes solid.
 * Indeterminate: a dithered band sweeps along the track. Colour changes
 * (done, paused) blend over ~200ms. Only draws while something is moving.
 *
 *   const bar = Progress.get(el);   // made on first use
 *   bar.set(64);                    // 0–100 (steps: the number of steps done)
 *   bar.set(0, { instant: true });
 *   bar.indeterminate(true);

Usage

Usage
import { Progress, ProgressRing, ProgressSteps } from "@/components/fabricui/progress";

export function Upload({ percent, done }: { percent: number; done: boolean }) {
  return <Progress aria-label="Uploading brand-assets.zip" value={percent} state={done ? "done" : undefined} />;
}

export function Export({ known, percent }: { known: boolean; percent: number }) {
  return <Progress aria-label="Export" indeterminate={!known} value={percent} />;
}

export function Sync({ percent }: { percent: number }) {
  return (
    <ProgressRing aria-label="Syncing" value={percent} size={104}>
      <b>{Math.round(percent)}%</b>
    </ProgressRing>
  );
}

export function Setup({ step }: { step: number }) {
  return <ProgressSteps aria-label="Workspace setup" steps={4} value={step} />;
}

Props

PropTypeDefault
value

0–100 (ProgressSteps: how many steps are done). It glides there on a spring that never runs past the truth.

number0
indeterminate

Not known yet: a dithered band sweeps along the track. Turn it off and the band hands over to the fill.

booleanfalse
state

done turns the fill green; paused greys it. The colour blends over.

"done" | "paused"—
size

Progress: 4, 6 or 8px tall. ProgressRing: a number, its width in px (72 by default).

"sm" | "md" | "lg""md"
steps

ProgressSteps: how many segments.

number—
ref

Set it from code; instant jumps without the glide (to reset to 0, say).

{ set(value, { instant }), indeterminate(on) }—
ProgressRing

The same, round. Its children sit in the middle.

component—
ProgressSteps

One segment per step: done ones fill; the one you're on is half-lit in dots.

component—