in

A simple, flexible React step wizard hook


React Stepper

A simple, flexible React step wizard hook.

Installation

npm install @xolos/react-stepper

or

yarn add @xolos/react-stepper

This library has peerDependencies listings for react and react-dom.

Example

import React from 'react';
import useStepper from '@xolos/react-stepper';

const stepIds = ['foo', 'bar', 'buzz'];
function App() {
  const {
    currentStepId,
    goToNextStep,
    goToPreviousStep,
  } = useStepper(stepIds);
  
  return (
    <div className="App">
      <button onClick={goToPreviousStep}>Previous Step</button>
      <button onClick={goToNextStep}>Next Step</button>
      <h1>{currentStepId}</h1>
    </div>
  );
}

export default App;

API

const {
	currentStepId,
	currentStepIndex,
	goToNextStep,
	goToPreviousStep,
	isFirstStep,
	isLastStep
} = useStepper(stepIds)

Options

Returns

  • currentStepId: string

  • currentStepIndex: number

  • goToNextStep: () => void

    The stepper will loop to the first step if moving past the last step.

  • goToPreviousStep: () => void

    The stepper will loop to the last step if moving past the first step.

  • isFirstStep: boolean

  • isLastStep: boolean

GitHub

https://github.com/omarnyte/react-stepper


Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

GIPHY App Key not set. Please check settings

Make a image editor with HTML, CSS and JS.

DIL KISI SE LYRICS – ARJUN KANUNGO