Socket
Socket
Sign inDemoInstall

react-formik-stepper

Package Overview
Dependencies
3
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-formik-stepper

A modern flexible step wizard component build for React Formik


Version published
Weekly downloads
1
decreased by-88.89%
Maintainers
1
Install size
48.5 kB
Created
Weekly downloads
 

Readme

Source

React Formik Stepper

npm

A flexible multistep wizard built for React and Formik

Install

npm install --save react-formik-stepper

or

yarn add react-formik-stepper

Import Component

import FormikStepper from 'react-formik-stepper';

JSX Syntax

Simply create a wrapper with and each child component will be treated as an individual step.

<FormikStepper initialValues={{}} onSubmit={}>
  <Step1 />
  <Step2
    validation={{
      email: yup.string().required(),
    }}
  />
  ...
  <Step5 />
  <WhateverComponentName />
</FormikStepper>

and then in each step

import { useFormikContext } from 'formik';

const formik = useFormikContext();

Props

Available in all steps.

PropData Type
previousStepfunction
nextStepfunction
goToStepfunction
firstStepnumber
lastStepnumber
<div>
  <!-- Variables -->
  <h2>Step {this.props.currentStep}</h2>
  <p>Total Steps: {this.props.totalSteps}</p>
  <!-- Functions -->
  <p><button onClick={this.props.previousStep}>Previous Step</button></p>
  <p><button onClick={this.props.nextStep}>Next Step</button></p>
  <p><button onClick={()=>this.props.goToStep(2)}>Step 2</button></p>
  <p><button onClick={this.props.firstStep}>First Step</button></p>
  <p><button onClick={this.props.lastStep}>Last Step</button></p>
</div>

FormikStepper Props

PropData TypeDescription
initialValuesValuesInitial field values of the form, Formik will make these values available to render methods component as values. https://formik.org/docs/api/formik#initialvalues-values
onSubmitfunctionYour form submission handler. https://formik.org/docs/api/formik#onsubmit-values-values-formikbag-formikbag--void--promiseany
onResetfunctionYour optional form reset handler. https://formik.org/docs/api/formik#onreset-values-values-formikbag-formikbag--void
validatefunctionI suggest using yup for validation in each step. However, validate is a dependency-free, out of the box way to validate your forms. https://formik.org/docs/api/withFormik#validate-values-values-props-props--formikerrorsvalues--promiseany
validateOnChangebooleanDefault is true. Determines if form validation should or should not be run after any array manipulations.
https://formik.org/docs/api/fieldarray#validateonchange-boolean
validateOnBlurbooleanDefault is true. Use this option to run validations on blur events. More specifically, when either handleBlur, setFieldTouched, or setTouched are called
https://formik.org/docs/api/withFormik#validateonblur-boolean
validateOnMountbooleanDefault is false. Use this option to tell Formik to run validation (at low priority) when the wrapped component mounts and/or initialValues change.
https://formik.org/docs/api/withFormik#validateonmount-boolean
enableReinitializebooleanDefault is false. Control whether Formik should reset the form if the wrapped component props change (using deep equality).
https://formik.org/docs/api/withFormik#enablereinitialize-boolean
animatebooleanDefault is true. Uses animation from Animate CSS

Step Props

PropData TypeDescription
validationobjectEnter validation for each step.

FAQs

Last updated on 05 Oct 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc