Skip to content

Progress

A bar that fills to show how much of something is done or used: an import, storage, a plan limit.

import { Progress, ProgressSkeleton } from '@sypnia/ui/react'

On this page
  1. A known amount
  2. A task that runs
  3. No known end
  4. Skeleton
  5. When to use it
  6. For everyone
  7. Props

A known amount

Four limits, from comfortable to full.

Storage3.1 of 5 GB
Team members4 of 5
Requests this month500,000 of 500,000
Columns matched8 of 8
Code
import { Progress } from '@sypnia/ui/react';

// The words say what is measured; the detail gives the numbers.
export default function Known() {
  return (
    <div className="sy-cols sy-cols--stack">
      <Progress label="Storage" value={3.1} max={5} detail="3.1 of 5 GB" />
      <Progress label="Team members" value={4} max={5} detail="4 of 5" tone="warn" />
      <Progress label="Requests this month" value={500000} max={500000} detail="500,000 of 500,000" tone="fail" />
      <Progress label="Columns matched" value={8} max={8} detail="8 of 8" tone="ok" />
    </div>
  );
}

A task that runs

Press «Import».

Importing order_items.csv0 of 3,811 rows
Code
import { useEffect, useState } from 'react';
import { Button, Progress } from '@sypnia/ui/react';

const total = 3811;
// Press «Import»: the bar and the numbers move together.
export default function Running() {
  const [rows, setRows] = useState(0);
  const [running, setRunning] = useState(false);
  useEffect(() => {
    if (!running) return;
    const t = setInterval(() => setRows((r) => { const n = Math.min(total, r + 137); if (n === total) setRunning(false); return n; }), 120);
    return () => clearInterval(t);
  }, [running]);
  return (
    <div className="sy-stack">
      <Progress label={rows === total ? 'order_items.csv imported' : 'Importing order_items.csv'} value={rows} max={total}
        detail={`${rows.toLocaleString('en')} of ${total.toLocaleString('en')} rows`} tone={rows === total ? 'ok' : undefined} />
      <div><Button disabled={running} onClick={() => { setRows(0); setRunning(true); }}>{rows === total ? 'Import again' : 'Import'}</Button></div>
    </div>
  );
}

No known end

A band of light moves along the bar; the words say what is going on.

Restoring the backup of November 16This can take a few minutes
Code
import { Progress } from '@sypnia/ui/react';

// Without a value: work is going on, and nobody promises when it ends.
export default function Unknown() {
  return <Progress label="Restoring the backup of November 16" detail="This can take a few minutes" />;
}

Skeleton

The real piece and its skeleton: the same box, so nothing moves when the data arrives.

Storage18 of 50 GB
Code
import { Progress, ProgressSkeleton } from '@sypnia/ui/react';

// How much of the plan is used, before the amount arrives. The skeleton has the same box as the real one, so nothing moves when the data arrives.
export default function Skeleton() {
  return (
    <div className="sy-stack">
      <Progress label="Storage" value={18} max={50} detail="18 of 50 GB" />
      <ProgressSkeleton />
    </div>
  );
}

When to use it

Use it when

  • A task with a known size is running: rows imported, files uploaded.
  • A limit is being used up: storage, members, requests. Change the tone as it gets close.
  • The work has no known end: leave value out and say in words what is happening.

Do not use it when

  • Content is loading: show its skeleton.
  • A button is working for a moment: the button’s busy state is enough.
  • It is a sequence of steps the person takes: that is a Stepper.

For everyone

  • It is a progress bar for screen readers, named by its label, with its percentage.
  • The numbers are also written beside it (detail), so nobody depends on the length of a bar.
  • Warning and failure tones change the colour; say the consequence in words near it.
  • The moving band of the unknown state stops under reduced motion.

Props

ProgressTypeDefault
labelrequired ReactNode
detail ReactNode
max number 100
tone "ok" | "warn" | "fail"
value number
ProgressSkeletonTypeDefault
detail boolean true
  1. A known amount
  2. A task that runs
  3. No known end
  4. Skeleton
  5. When to use it
  6. For everyone
  7. Props

    Search pages, sections and terms