ProgressSteps
The steps of something the system is doing, as they happen: a deploy, an import. Each says whether it is done, running, waiting, failed or skipped.
import { ProgressSteps, ProgressStepsSkeleton } from '@sypnia/ui/react'
A deploy as it happens
- Build, done
- Run the tests, done
- Upload, running12 of 40 files
- Switch traffic, waiting
Code
import { useEffect, useState } from 'react';
import { Button, ProgressSteps, ProgressStepsSkeleton, type ProgressStep } from '@sypnia/ui/react';
// A deploy as it happens. Press «Deploy again» to watch the light move down; the skeleton is on the right.
const names = ['Build', 'Run the tests', 'Upload', 'Switch traffic'];
export default function Deploy() {
const [at, setAt] = useState(2);
useEffect(() => { if (at >= names.length) return; const id = setTimeout(() => setAt(at + 1), 1400); return () => clearTimeout(id); }, [at]);
const steps: ProgressStep[] = names.map((label, i) => ({ label, state: i < at ? 'done' : i === at ? 'running' : 'waiting', detail: i === 2 && i === at ? '12 of 40 files' : undefined }));
return (
<div className="sy-grid">
<div className="sy-stack"><ProgressSteps label="Deploy of shop" steps={steps} /><Button size="sm" onClick={() => setAt(0)}>Deploy again</Button></div>
<ProgressStepsSkeleton steps={4} />
</div>
);
} A step that failed
- Read the file, done4,310 rows
- Check the columns, failedThe column «email» is empty in 12 rows. Fill them or remove those rows and import again.
- Save the rows, skipped
Code
import { ProgressSteps } from '@sypnia/ui/react';
// When a step fails, the ones after it are skipped and the failed one says why.
export default function Failed() {
return <ProgressSteps label="Import of customers.csv" steps={[
{ label: 'Read the file', state: 'done', detail: '4,310 rows' },
{ label: 'Check the columns', state: 'failed', detail: 'The column «email» is empty in 12 rows. Fill them or remove those rows and import again.' },
{ label: 'Save the rows', state: 'skipped' },
]} />;
} When to use it
Use it when
- Long tasks with clear steps the person may wait for.
- When a step fails, say why in its
detailand skip the rest.
Do not use it when
- Steps the person does: use a Stepper or a Wizard.
- Tasks of a few seconds: a busy button is enough.
For everyone
- Each state is said in words to screen readers, not only with the marks.
- The running step is
aria-current="step".
Props
| ProgressSteps | Type | Default |
|---|---|---|
labelrequired | string | |
stepsrequired | ProgressStep[] |
| ProgressStepsSkeleton | Type | Default |
|---|---|---|
steps | number | 4 |