alpha

ProgressList

A ProgressList displays the steps of a multi-step process and indicates which of the steps the user has completed.

Theme 
Example
ProgressList.tsx
ProgressList.css
import {ProgressList, ProgressListItem} from './ProgressList';

<ProgressList aria-label="Checkout" selectedKey="payment">
  <ProgressListItem id="cart">Cart</ProgressListItem>
  <ProgressListItem id="shipping">Shipping</ProgressListItem>
  <ProgressListItem id="payment">Payment</ProgressListItem>
  <ProgressListItem id="review">Review</ProgressListItem>
</ProgressList>

Content

ProgressList follows the Collection Components API, accepting both static and dynamic collections. This example shows a dynamic collection, passing a list of objects to the items prop, and a function to render the children.

import {ProgressList, ProgressListItem} from './ProgressList';

let steps = [
  {id: 'account', label: 'Account'},
  {id: 'profile', label: 'Profile'},
  {id: 'settings', label: 'Settings'},
  {id: 'confirm', label: 'Confirm'}
];

<ProgressList
  aria-label="Sign up"
  items={steps}
  selectedKey="profile">
  {step => <ProgressListItem>{step.label}</ProgressListItem>}
</ProgressList>

Current step

Use the selectedKey prop to set the current step. The current step is marked with aria-current="step", and the steps before it are marked as completed. Use the data-current and data-completed attributes to style them.

import {ProgressList, ProgressListItem} from './ProgressList';
import {Button} from './Button';
import {useState} from 'react';

let steps = [
  {id: 'cart', label: 'Cart'},
  {id: 'shipping', label: 'Shipping'},
  {id: 'payment', label: 'Payment'},
  {id: 'review', label: 'Review'}
];

function Example() {
  let [index, setIndex] = useState(1);

  return (
    <div style={{display: 'flex', flexDirection: 'column', alignItems: 'start', gap: 16, maxWidth: '100%'}}>
      <ProgressList
        aria-label="Checkout"
        items={steps}
        selectedKey={steps[index].id}>
        {step => <ProgressListItem>{step.label}</ProgressListItem>}
      </ProgressList>
      <div style={{display: 'flex', gap: 8}}>
        <Button onPress={() => setIndex(Math.max(0, index - 1))}>Back</Button>
        <Button onPress={() => setIndex(Math.min(steps.length - 1, index + 1))}>Next</Button>
      </div>
    </div>
  );
}

API

<ProgressList>
  <ProgressListItem>
    <ProgressListItemContent />
  </ProgressListItem>
</ProgressList>

ProgressList

A ProgressList displays the steps of a multi-step process and indicates which of the steps the user has completed.

NameType
childrenReactNode | (item: T) => ReactNode

The contents of the collection.

itemsIterable<T>

Item objects in the collection.

dependenciesReadonlyArray<any>

Values that should invalidate the item cache when using dynamic collections.

selectedKeyKey

The id of the currently selected ProgressListItem. Steps before it in the collection are marked as completed, and steps after it are marked as not completed.

Default className: react-aria-ProgressList

ProgressListItem

A ProgressListItem represents an individual step within a <ProgressList>.

NameType
idKey

A unique id for the step, which is compared against the selectedKey of the ProgressList.

children<>

The children of the component. A function may be provided to alter the children based on component state.

Default className: react-aria-ProgressListItem

Render PropCSS Selector
isCurrentCSS Selector: [data-current]
Whether the step is the currently selected step.
isCompletedCSS Selector: [data-completed]
Whether the step is rendered before the currently selected step.
stepNumberCSS Selector: —
The position of the step within the ProgressList, starting from 1.

ProgressListItemContent

A ProgressListItemContent renders the content of a <ProgressListItem>.

NameType
childrenReactNode

The children of the component.