2.2.1 • Published 3 months ago

@spark-web/vertical-stepper v2.2.1

Weekly downloads
-
License
-
Repository
github
Last release
3 months ago

title: Vertical Stepper storybookPath: data-display-vertical-stepper

isExperimentalPackage: true

Vertical stepper display progress through a sequence of logical and numbered steps.

Example

const [activeIndex, setActiveIndex] = React.useState(2);

return (
  <Box padding="large">
    <VerticalStepper activeIndex={activeIndex}>
      <Step>
        <Step.Heading title="Step 1" />
        <Step.Content>
          <Stack gap="medium">
            <Text>
              Lorem Ipsum is simply dummy text of the printing and typesetting
              industry. Lorem Ipsum has been the industry's standard dummy text
              ever since the 1500s, when an unknown printer took a galley of
              type and scrambled it to make a type specimen book. It has
              survived not only five centuries, but also the leap into
              electronic typesetting, remaining essentially unchanged. It was
              popularised in the 1960s with the release of Letraset sheets
              containing Lorem Ipsum passages, and more recently with desktop
              publishing software like Aldus PageMaker including versions of
              Lorem Ipsum.
            </Text>
            <Button
              tone="primary"
              onClick={() => {
                setActiveIndex(activeIndex + 1);
              }}
            >
              Next
            </Button>
          </Stack>
        </Step.Content>

        <Step.CompletedContent>
          <Text>Success 🎉!</Text>
        </Step.CompletedContent>
      </Step>

      <Step>
        <Step.Heading
          title="Step 2"
          renderActionButton={({ isCompleted, stepIndex }) =>
            isCompleted && (
              <Button
                type="button"
                tone="info"
                onClick={() => {
                  setActiveIndex(stepIndex);
                }}
                size="medium"
              >
                <PencilAltIcon size="xxsmall" />
                Edit
              </Button>
            )
          }
        />
        <Step.Content
          render={({ stepIndex }) => (
            <Stack gap="small">
              <Text>Content number {stepIndex + 1}</Text>

              <Button
                tone="secondary"
                onClick={() => {
                  setActiveIndex(stepIndex - 1);
                }}
              >
                Back
              </Button>

              <Button
                tone="primary"
                onClick={() => {
                  setActiveIndex(stepIndex + 1);
                }}
              >
                Next
              </Button>
            </Stack>
          )}
        />
        <Step.CompletedContent
          render={({ stepIndex }) => (
            <Text>Completed Step {stepIndex + 1}!! 🎉</Text>
          )}
        />
      </Step>

      <Step>
        <Step.Heading title="Step 3" />
        <Step.Description>
          <Text size="small" tone="muted">
            Lorem Ipsum is simply dummy text of the printing and typesetting
            industry. Lorem Ipsum has been the industry's standard dummy text
            ever since the 1500s, when an unknown printer took a galley of type
            and scrambled it to make a type specimen book.
          </Text>
        </Step.Description>
        <Step.Content>
          <Stack gap="medium">
            <Text>
              Lorem Ipsum is simply dummy text of the printing and typesetting
              industry. Lorem Ipsum has been the industry's standard dummy text
              ever since the 1500s, when an unknown printer took a galley of
              type and scrambled it to make a type specimen book. It has
              survived not only five centuries, but also the leap into
              electronic typesetting, remaining essentially unchanged. It was
              popularised in the 1960s with the release of Letraset sheets
              containing Lorem Ipsum passages, and more recently with desktop
              publishing software like Aldus PageMaker including versions of
              Lorem Ipsum.
            </Text>
            <Button
              tone="secondary"
              onClick={() => {
                setActiveIndex(activeIndex - 1);
              }}
            >
              Back
            </Button>
          </Stack>
        </Step.Content>
      </Step>
    </VerticalStepper>
  </Box>
);

Props