Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Designing a Stepper Form in ReactJS

  • Last Updated : 19 Sep, 2021

Steppers display progress through a sequence of logical and numbered steps. They may also be used for navigation. Steppers may display a transient feedback message after a step is saved.

In this article, we will learn how to create a vertical stepper form using react and material-ui. We will create a vertical stepper and add a form container to it. At all stages of stepper-form, we will add different details. It’s just like you have different stages to fill-up the form and after completing all the steps you will reach the final.

Creating React-app

Step 1: Create react app using the following command.

npx create-react-app my-first-app


Step 2: Change directory to that folder by executing command :

cd my-first-app

Step 3: Install the necessary dependencies. Go to the directory ‘src’ and execute command prompt there and run command

npm install @material-ui/core/Stepper
npm install @material-ui/core/Step
npm install @material-ui/core/StepLabel

File Structure: It will look like the following.

Step 4: Importing < GeekStepper/> component in root component.


import GeekStepper from './StepperForm'
function App() {
  return (
    <div className="App">
      <GeekStepper />
export default App;

Step 5: In this file, we will implement Stepper Form to submit Personal Details, Education Details, and Address of a user. Stepper is created using material-ui in react. We have imported different ui-classes in this component like Stepper, StepLabel etc. 

Form is implemented using proactive step and ActiveStep. These steps are used to display the component of the form which is active and to return back.


import React from 'react';
import { makeStyles, Theme, createStyles } 
        from '@material-ui/core/styles';
import Stepper from '@material-ui/core/Stepper';
import Step from '@material-ui/core/Step';
import StepLabel from '@material-ui/core/StepLabel';
import StepContent from '@material-ui/core/StepContent';
import Button from '@material-ui/core/Button';
import Paper from '@material-ui/core/Paper';
import Typography from '@material-ui/core/Typography';
const useStyles = makeStyles((theme: Theme) =>
    root: {
      width: '100%',
    button: {
      marginTop: theme.spacing(1),
      marginRight: theme.spacing(1),
    actionsContainer: {
      marginBottom: theme.spacing(2),
    resetContainer: {
      padding: theme.spacing(3),
function getSteps() {
  return [<b style={{color:'purple'}}>'Enter Personal Details'</b>, 
  <b style={{color:'purple'}}>'Enter Education Details'</b>, 
  <b style={{color:'purple'}}>'Enter Address'</b>];
function getStepContent(step: number) {
  switch (step) {
    case 0:
      return (
        <form class="form-group">
        <label>First Name</label>
        <input type="text" placeholder="First Name"></input>
        <label>Last Name</label>
        <input type="text" placeholder="Last Name"></input>
    case 1:
      return (
        <form class="form-group">
        <label>High School Percentage</label>
        <input type="number" placeholder="High School Percentage"></input>
        <label>Graduation percentage</label>
        <input type="number" placeholder="Graduation Percentage"></input>
    case 2:
      return (
        <form class="form-group">
        <label>Permanent Address</label>
        <input type="text" placeholder="Permanent Address"></input>
        <label>Temporary Address</label>
        <input type="text" placeholder="Temporary Address"></input>
      return 'Unknown step';
export default function GeekStepper() {
  const classes = useStyles();
  const [activeStep, setActiveStep] = React.useState(0);
  const steps = getSteps();
  const handleNext = () => {
    setActiveStep((prevActiveStep) => prevActiveStep + 1);
  const handleBack = () => {
    setActiveStep((prevActiveStep) => prevActiveStep - 1);
  const handleReset = () => {
  return (
    <div className={classes.root}>
      <h1>GeeksforGeeks Stepper Form</h1>
      <Stepper activeStep={activeStep} orientation="vertical">
        {, index) => (
          <Step key={label}>
              <div className={classes.actionsContainer}>
                    disabled={activeStep === 0}
                    {activeStep === steps.length - 1 ? 'Finish' : 'Next'}
      {activeStep === steps.length && (
        <Paper square elevation={0} className={classes.resetContainer}>
          <Typography>Form is submitted</Typography>
          <Button onClick={handleReset} className={classes.button}>

Step to run the application: Run your app by executing below command in src

npm start


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!