npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-headless-multi-stepper

v0.1.2

Published

Design your own Multi Stepper component without having to worry about the logic. Then this tiny and performant package is for you. `react-headless-multi-stepper` is ideal if you are working with a utility-based css framework like TailwindCSS. `react-headl

Downloads

4

Readme

React Headless Multi Stepper

Design your own Multi Stepper component without having to worry about the logic. Then this tiny and performant package is for you. react-headless-multi-stepper is ideal if you are working with a utility-based css framework like TailwindCSS. react-headless-multi-stepper offers plenty of customization through generics and is also fully typed.

npm

issues stargazers

Install

yarn add react-headless-multi-stepper

Demo: Unstyled & TailwindCSS

Storybook

Usage

import { MultiStepper } from "react-headless-multi-stepper";

...
return (
  <MultiStepper
    {...args}
    RootContainer={<div />}
    MainLabelContainer={<ul />}
    SubLabelContainer={<ul />}
    ContentContainer={<div />}
    onChange={(step)}
    onCompleted={() => alert("onCompleted")}
    renderMainLabel={(props) => <li>{props.label}</li>}
    renderSubLabel={(props) => <li>{props.label}</li>}
  >
    <MultiStepper.VerticalStep name="1" label="step 1">
      <MultiStepper.HorizontalStep name="1.1" label="1.1">
        {({ goPrevious, goNext }) => (
          <div>
            Content 1.1
            <button onClick={goPrevious}>previous</button>
            <button onClick={goNext}>next</button>
          </div>
        )}
      </MultiStepper.HorizontalStep>
      <MultiStepper.HorizontalStep name="1.2" label="1.2">
        {({ goPrevious, goNext }) => (
          <div>
            Content 1.2
            <button onClick={goPrevious}>previous</button>
            <button onClick={goNext}>next</button>
          </div>
        )}
      </MultiStepper.HorizontalStep>
      <MultiStepper.HorizontalStep name="1.3" label="1.3">
        {({ goPrevious, goNext }) => (
          <div>
            Content 1.3
            <button onClick={goPrevious}>previous</button>
            <button onClick={goNext}>next</button>
          </div>
        )}
      </MultiStepper.HorizontalStep>
    </MultiStepper.VerticalStep>
    <MultiStepper.VerticalStep name="2" label="step 2">
      <MultiStepper.HorizontalStep name="2.1" label="2.1">
        {({ goPrevious, goNext }) => (
          <div>
            Content 2.1
            <button onClick={goPrevious}>previous</button>
            <button onClick={goNext}>next</button>
          </div>
        )}
      </MultiStepper.HorizontalStep>
      <MultiStepper.HorizontalStep name="2.2" label="2.2">
        {({ goPrevious, goNext }) => (
          <div>
            Content 2.2
            <button onClick={goPrevious}>previous</button>
            <button onClick={goNext}>next</button>
          </div>
        )}
      </MultiStepper.HorizontalStep>
      <MultiStepper.HorizontalStep name="2.3" label="2.3">
        {({ goPrevious, goNext }) => (
          <div>
            Content 2.3
            <button onClick={goPrevious}>previous</button>
            <button onClick={goNext}>next</button>
          </div>
        )}
      </MultiStepper.HorizontalStep>
    </MultiStepper.VerticalStep>
    <MultiStepper.VerticalStep name="3" label="step 3">
      <MultiStepper.HorizontalStep name="3.1" label="3.1">
        {({ goPrevious, goNext }) => (
          <div>
            Content 3.1
            <button onClick={goPrevious}>previous</button>
            <button onClick={goNext}>next</button>
          </div>
        )}
      </MultiStepper.HorizontalStep>
    </MultiStepper.VerticalStep>
  </MultiStepper>
);

An example of a styled version can be found in stories/MultiStepper.stories.tsx.

MultiStepper props

The following table contains all optional and required props for the MultiStepper. The library is strictly typed and uses generics to support many different kinds of data.

| Name | Type | Default | Description | | ------------------ | -------------------------------------- | ------- | --------------------------------------------------------------------------------------------- | | dataTestId | string | | Places a data-testid on several elements | | RootContainer | React.ReactElement | div | Root element of the MultiStepper. | | MainLabelContainer | React.ReactElement | ul | Containing element for the main labels. | | SubLabelContainer | React.ReactElement | ul | Containing element for the sub labels. | | ContentContainer | React.ReactElement | div | Containing element for the SubLabelContainer and step content. | | renderMainLabel* | IRenderLabel** | | Render prop for the label of the vertical step. | | renderSubLabel* | IRenderLabel** | | Render prop for the label of the horizontal step. | | onChange* | (name: string) => void | | Fires for every next and previous navigation action. Name refers to the newly activated step. | | onCompleted* | () => void | | Fires on completion of the entire flow. | | children* | React.ReactElement <IVerticalStep>[] | | A number of VerticalStep components. |

*these are required
**IRenderLabel contains all information to render your horizontal or vertical label (i.e. activeIndex, label, name, index, array).

VerticalStep props

The following table contains all optional and required props for the VerticalStep component. VerticalSteps are placed as children inside the MultiStepper.

| Name | Type | Description | | ---------- | -------------------------------------------------------------------------------- | ------------------------------------------------------- | | name* | string | Unique string to distinguish between all vertical steps | | label* | string | Display this value to the user in the stepper. | | children* | React.ReactElement<IHorizontalStep> or React.ReactElement<IHorizontalStep>[] | A number of HorizontalStep components. |

*these are required

HorizontalStep props

The following table contains all optional and required props for the HorizontalStep component. HorizontalSteps are placed as children inside the VerticalStep.

| Name | Type | Description | | ---------- | ----------------------- | --------------------------------------------------------- | | name* | string | Unique string to distinguish between all horizontal steps | | label* | string | Display this value to the user in the stepper. | | children* | ({goPrevious,goNext}) | Render prop for children |

*these are required
** IHorizontalStep: goPrevious and goNext are both callback functions that return nothing.

Authors