import { Canvas, Controls, Meta, Title } from '@storybook/addon-docs/blocks';
import * as SpinnerSequenceStories from './SpinnerSequence.stories';
<Meta of={SpinnerSequenceStories} name='Usage' />
<Title />
## Purpose
A Spinner that tells people what is happening. It shows a list of steps, one text at a time, then ends on an illustration and a final text. Use it for a wait of several seconds with stages, such as setting up an account. For a short or single-stage wait, use the Spinner.
You set the texts, how long each shows (`defaultDuration`, or `duration` on a step) and the illustration (`illustrationName`, or your own `illustration`).
## Usage
- Write each step as what the system is doing now, and the final text as what happens next.
- Timers are a guess. When the real work can say where it is, set `activeStep` and move the steps yourself.
- `onComplete` fires when the final state shows, for example to move to the next page. A timed sequence reaches it once; a controlled one fires again each time `activeStep` goes back and reaches the end again.
- A timed sequence runs once. To run it again, remount it (change its `key`); a controlled one goes back when `activeStep` goes back.
## Accessibility
- The text is one polite live region (`role='status'`). Each new step text and the final text replace the previous one, so a screen reader reads each once. Write each text so it makes sense on its own.
- The spinner and the illustration are decorative and hidden from assistive technology, so nothing is announced twice and the Spinner's own "Loading" label is not read. A custom `illustration` is hidden too, so it cannot carry meaning: the final text must say it.
- Nothing in the component is interactive: no focus and no keyboard behavior.
- The fade between the spinner and the illustration, and the text fade, stop when the person has asked for reduced motion. The timing still runs, so the texts still change on schedule.
- Every text comes from props (`steps`, `finalLabel`), so it can be translated. Two steps in a row with the same text are not announced again.
- The text uses the foreground color on the surface it sits on. Check its contrast, and the illustration's, in light and dark.
## Implementation
See the table below for the available props. The other stories show every variant and state.
- `size` — Spinner size (default `5xl`). The illustration is drawn at the same size, so nothing moves when the final state shows.
<hr />
<Canvas of={SpinnerSequenceStories.Default} />
<Controls of={SpinnerSequenceStories.Default} />
<hr />
<Canvas of={SpinnerSequenceStories.ControlledByTheWork} />
SpinnerSequence
A new component, SpinnerSequence, that composes the existing PDS v2 Spinner and Illustration (the Spinner is not changed).
Net-new componentOpen in Storybook