How to create a beautiful stepper using bootstrap and Contrast
Tags: react, webdev, programming, codenewbie
Published: 2021-08-02 11:19:21

---
title: How to create a beautiful stepper using bootstrap and Contrast
published: true
date: 2021-04-20 01:16:04 UTC
tags: [react, webdev, programming, codenewbie]
canonical_url: https://www.devwares.com/blog//create-stepper-with-contrast
cover_image: https://devwares.com/blog/images/reactArticle8.png
---

## How to create a stepper component in react using bootstrap and Contrast.

Stepper is a component that displays content as a process with defined by user milestones. Following steps are separated and connected by buttons.
This is a great solution for a variety of registration forms, where you don't want to scare the user with loads of fields and questions.
Stepper can be aligned vertically as well as horizontally.

Examples of React Bootstrap steps use:
- Registration form
- Payment gateway
- Tutorial with steps

We are going to look at how to create this stepper today using a react library known as contrast. 

Contrast also known as CDBReact is a react library which is an Elegant UI kit with full bootstrap support that has reusable components for building mobile-first, responsive websites, and web apps.

To use stepper you need to download the pro version here.

**Prerequisites**

The stepper would be built using React, Bootstrap, and CDBReact. You don’t need to have any previous knowledge of CDBReact but the following are necessary:
- Basic React Knowledge
- JavaScript knowledge
- Basic Bootstrap knowledge
- NPM installed

**Setup**

First Check that you have node installed. To do this, run the following command in your terminal.

**Code:**

```jsx
node-v
```

This should show you the current version of node you have installed on your machine.
If you don’t have nodejs installed, download it here.
Installing node also installs npm on your PC but you can still confirm using npm-v. Now that we have node installed, we can start up our React project by going to the directory of our choice and running

**Code:**

```jsx
npx create-react-app stepper-app
```

I named the project Stepper-app but you can use any name of your choice.

**Installing CDBReact-pro**

Before we install our CDBReact we have to download the pro version [here](https://devwares.com/product/contrast-pro) first. Then, we can go ahead to install them in our project. It is advised to add the file to the root of the project by running:

```jsx
npm install --save ./path-to-the-cdbreact-pro-tgz-file
```

Or using Yarn

```jsx
yarn add ./path-to-the-cdbreact-pro-tgz-file
```


Note that we don’t need to install bootstrap or add it anywhere in our project as CDBReact does that for us upon installation.

**Stepper**

We can now create a file named stepper.js. This is where we are going to import the stepper and other components. This is also where we will be writing our code.
The contrast stepper component must first be imported before using it.

**Code:**

```jsx
import React, { useState } from "react";
import { CDBStepper, CDBStep, CDBInput, CDBBtn, CDBContainer } from "cdbreact-pro";
```

In the code we imported some imported components we need to build a stepper. They include 
- CDBStepper
- CDBStep
- CDBInput
- CDBBtn
- CDBContainer

**Code:**

```jsx
const Stepper = () => {

  const [active, setActive] = useState(1)

  const handleNextPrevClick = (a) => {
    setActive(a)
  };

  const handleSubmission = () => {
    alert("Form submitted!");
  };

  return (
    <CDBContainer className="d-flex">
      <CDBContainer style={{ height: "500px", width: "150px" }}>
        <CDBStepper direction="vertical">
          <CDBStep
            id={1}
            far
            icon="folder-open"
            name="Basic Information"
            handleClick={() => handleNextPrevClick(1)}
            active={active}
          />
          <CDBStep
            id={2}
            icon="pencil-alt"
            name="Personal Data"
            handleClick={() => handleNextPrevClick(2)}
            active={active}
          />
          <CDBStep
            id={3}
            icon="dragon"
            name="Terms and Conditions"
            handleClick={() => handleNextPrevClick(3)}
            active={active}
          />
          <CDBStep
            id={4}
            icon="check"
            name="Finish"
            handleClick={() => handleNextPrevClick(4)}
            active={active}
          />
        </CDBStepper>
      </CDBContainer>
      <CDBContainer
        style={{
          height: "500px",
          width: "100%",
          display: "flex",
          alignItems: "center",
        }}
      >
        {active === 1 && (
          <CDBContainer md="12">
            <h3
              className="font-weight-bold pl-0 my-4 "
              style={{
                width: "100%",
                fontSize: "30px",
                textAlign: "center",
              }}
            >
              Your Information
            </h3>
            <CDBInput label="Email" className="mt-4" />
            <CDBInput label="username" className="mt-4" />
            <CDBInput label="Password" className="mt-4" />
            <CDBInput label="Repeat Password" className="mt-4" />
            <CDBBtn
              color="dark"
              block
              flat
              className="float-right"
              onClick={() => handleNextPrevClick(2)}
            >
              Next
            </CDBBtn>
          </CDBContainer>
        )}
        {active === 2 && (
          <CDBContainer md="12">
            <h3
              className="font-weight-bold pl-0 my-4"
              style={{
                width: "100%",
                fontSize: "30px",
                textAlign: "center",
              }}
            >
              Personal Data
            </h3>
            <CDBInput label="First Name" className="mt-3" />
            <CDBInput label="Second Name" className="mt-3" />
            <CDBInput label="Surname" className="mt-3" />
            <CDBInput label="Address" type="textarea" rows="2" />
            <CDBBtn
              color="light"
              flat
              className="float-left"
              onClick={() => handleNextPrevClick(1)}
            >
              Previous
            </CDBBtn>
            <CDBBtn
              color="dark"
              flat
              className="float-right"
              onClick={() => handleNextPrevClick(3)}
            >
              Next
            </CDBBtn>
          </CDBContainer>
        )}
        {active === 3 && (
          <CDBContainer md="12">
            <h3
              className="font-weight-bold pl-0 my-4"
              style={{
                width: "100%",
                fontSize: "30px",
                textAlign: "center",
              }}
            >
              Terms and conditions
            </h3>
            <CDBInput
              label="I agreee to the terms and conditions"
              type="checkbox"
              id="checkbox3"
            />
            <CDBInput
              label="I want to receive newsletter"
              type="checkbox"
              id="checkbox4"
            />
            <CDBBtn
              color="light"
              className="float-left"
              flat
              onClick={() => handleNextPrevClick(2)}
            >
              Previous
            </CDBBtn>
            <CDBBtn
              color="dark"
              className="float-right"
              flat
              onClick={() => handleNextPrevClick(4)}
            >
              Next
            </CDBBtn>
          </CDBContainer>
        )}
        {active === 4 && (
          <CDBContainer md="12">
            <h3
              className="font-weight-bold pl-0 my-4"
              style={{
                width: "100%",
                fontSize: "30px",
                textAlign: "center",
              }}
            >
              Finish
            </h3>
            <h2 className="text-center font-weight-bold my-4">
              Registration completed!
            </h2>
            <CDBBtn
              color="light"
              flat
              className="float-left"
              onClick={() => handleNextPrevClick(3)}
            >
              Previous
            </CDBBtn>
            <CDBBtn
              color="success"
              flat
              className="float-right"
              onClick={handleSubmission}
            >
              Submit
            </CDBBtn>
          </CDBContainer>
        )}
      </CDBContainer>
    </CDBContainer>
  );
};

export default Stepper;
```

In the above code, we added styling to the various components we have imported to create the stepper.

**Code**

```jsx
import './App.css';
import Stepper from './stepper';

function App() {
  return (
    <Router>
      <div className="App">
        <Stepper />
      </div>
    </Router>
  );
}

export default App;
```

**Conclusion**

Building a stepper using contrast is quite simple and allows you to use several tools including bootstrap styling without installing bootstrap to create your stepper. You can also  check out some other features you can use in CDBReact Stepper Docs . you can also check the code here in our github.


###Create Stunning Websites and Web Apps

Building different custom components in react for your web apps or websites can get very stressful. Thats why we decided to build contrast. We have put together a UI kit with over 10000+ components, 5 admin dashboards and 23 additional different pages template for building almost any type of web app or webpage into a single product called Contrast Pro. [Try contrast pro!](https://www.devwares.com/product/contrast-pro)

![Contrast Design Boostrap](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ulsutxnzjpbpaauhvbew.png)

Contrast React Bootstrap PRO is a Multipurpose pro template, UI kit to build your next landing, admin, SAAS, prelaunch, etc. project with a clean, well documented, well crafted template and UI components. [Learn more about Contrast Pro](https://www.devwares.com/product/contrast-pro) 


## Resources 

- [Link to the Github Code](https://github.com/Iheanacho-ai/Tailwind-react-modal)

- [Link to the Tailwind CSS Modals Docs](https://tailwindui.com/components/application-ui/overlays/modals)

- [Get Tailwind CSS PRO](https://tailwindui.com/pricing)

- [Get Contrast PRO](https://www.devwares.com/product/contrast-pro)

- [Link to the modal documentation](https://www.devwares.com/docs/contrast/javascript/components/modal)

- [How to create Tailwind CSS Modal](https://www.devwares.com/blog/how-to-create-tailwind-css-modal)

- [How to use tailwind CSS in HTML]  (https://www.devwares.com/blog/how-to-use-tailwind-css-in-HTML)

- [Get Contrast PRO](https://www.devwares.com/product/contrast-pro)

- [Why tailwind CSS is good](https://www.devwares.com/blog/why-tailwind-css-is-good)

- [How to use Tailwind CSS in Nextjs](https://www.devwares.com/blog/tailwind-css-in-nextjs)

- [How to create Tailwind CSS Components for your Website](https://www.devwares.com/blog/how-to-create-tailwind-css-components-for-your-website)

- [How to create Tailwind CSS Animation](https://www.devwares.com/blog/create-animation-with-tailwind-css/)

- [Tailwind grid-How to use tailwind CSS grid templates in your project](https://www.devwares.com/blog/how-to-add-tailwind-css-grid-to-your-project/)

- [How to create a Beautiful Responsive Navigation bar Using Tailwind CSS](https://www.devwares.com/blog/how-to-create-a-beautiful-responsive-navbar-using-tailwind-css/)

- [Tailwind form-How to create and style a Responsive Form using Tailwind CSS](https://www.devwares.com/blog/how-to-create-and-style-a-responsive-form-using-tailwindcss/)

- [Tailwind CSS Flex: How to use Tailwind CSS Flex](https://www.devwares.com/blog/how-to-use-tailwind-css-flex/)

- [How to use tailwind CSS padding, margin and border in your project](https://www.devwares.com/blog/how-to-use-tailwind-css-padding-margin-and-border-in-your-project/)

- [Tailwind CSS CDN-How to use the Tailwind CSS JIT CDN](https://www.devwares.com/blog/how-to-use-the-tailwind-css-JIT-CDN/)

- [How to set up your first Tailwind CSS Project](https://www.devwares.com/blog/setting-up-your-first-project-using-tailwind-css/)

- [How to use Tailwind CSS in HTML](https://www.devwares.com/blog/how-to-use-tailwind-css-in-HTML/)

- [Tailwind CSS table-How to Create Tailwind CSS tables](https://www.devwares.com/blog/how-to-create-tailwind-css-tables/)

- [How to set up your first Tailwind CSS Project](https://www.devwares.com/blog/setting-up-your-first-project-using-tailwind-css/)

- [Why is tailwind CSS better than other CSS framework](https://www.devwares.com/blog/why-tailwind-css-is-good/)

- [10 tailwind CSS templates and themes](https://www.devwares.com/blog/tailwind-css-10-templates-and-themes/)

- [How to add tailwind CSS colors and Fonts to your project](https://www.devwares.com/blog/how-to-add-tailwind-css-colors-and-fonts-to-your-project/)

- [Differences between Tailwind CSS and SASS](https://www.devwares.com/blog/differences-between-tailwind-css-and-sass/)

- [Differences Between Tailwind CSS and Bootstrap](https://www.devwares.com/blog/diffrences-between-tailwind-css-and-bootstrap/)

- [10 Awesome projects built with Tailwind CSS](https://www.devwares.com/blog/awesome-10-projects-built-with-tailwind/).

- [How to install Tailwind CSS in Vue.js](https://www.devwares.com/blog/how-to-install-tailwind-css-in-vuejs/).

- [How to use Tailwind CSS in React](https://www.devwares.com/blog/how-to-use-tailwind-css-in-react/)

- [How to install Tailwind CSS with Laravel](https://www.devwares.com/blog/how-to-install-tailwind-css-in-laravel/)

- [How to create react date picker](https://www.devwares.com/blog/create-datepicker-with-contrast/)

- [React bootstrap 5 form-How to create React forms](https://www.devwares.com/blog/how-to-create-and-style-a-responsive-form-using-tailwindcss/).

- [How to create a beautiful React multiselect](https://www.devwares.com/blog/create-multiselect-with-contrast/).

- [How to create a beautiful React Bootstrap progress bar](https://www.devwares.com/blog/create-progress-with-contrast/).

- [How to create a beautiful React Bootstrap select with icons](https://www.devwares.com/blog/create-select-with-contrast/).

- [How to create a beautiful Bootstrap 5 stepper](https://www.devwares.com/blog/create-stepper-with-contrast/)

- [How to create a beautiful React Bootstrap table]
(https://www.devwares.com/blog/create-tables-with-contrast/)

- [How to create beautiful React Bootstrap tabs](https://www.devwares.com/blog/create-tabs-with-contrast/)

- [How to create a Beautiful Responsive Navigation bar Using Tailwind CSS](https://www.devwares.com/blog/how-to-create-a-beautiful-responsive-navbar-using-tailwind-css/)

- [Tailwind Modal-How to create a React Modal using Tailwind CSS.](https://www.devwares.com/blog/how-to-create-a-react-modal-using-tailwind-css/)

- [How to create a Bootstrap 5 Modal.](https://www.devwares.com/blog/how-to-create-a-bootstrap5-modal/)

- [How to Create React Tabs with Tailwind CSS](https://www.devwares.com/blog/how-to-create-react-tabs-with-tailwind-css/)

- [How to implement dark mode in React using tailwind css](https://www.devwares.com/blog/how-to-implement-dark-mode-in-tailwind-css/)

- [How to Implement a React Step Progress Bar Using Tailwind CSS](https://www.devwares.com/blog/how-to-implement-a-react-step-progress-bar-using-tailwind-css/)