Open In App

ReactJS Reactstrap Form Component

Improve
Improve
Like Article
Like
Save
Share
Report

Reactstrap is a popular front-end library that is easy to use React Bootstrap 4 components. This library contains the stateless React components for Bootstrap 4. The Form component is used when the user needs to create an instance or collect information. We can use the following approach in ReactJS to use the ReactJS Reactstrap Form Component.

Input Props:

  • children: It is used to pass the children element to this component.
  • type: It is used to denote the type like radio, checkbox, select, etc.
  • size: It is used to denote the size of this component.
  • bsSize: It is used to denote the bs size like large, small, etc.
  • state: It is used to denote the state for this component.
  • valid: It is used to apply the is-valid class when this is set to true.
  • invalid: It is used to apply the is-invalid class when this is set to true.
  • tag: It is used to pass in custom elements to use.
  • innerRef: It is used to get a reference to the DOM element.
  • static: It is used to indicate whether the static class is applied or not.
  • plaintext: It is used to indicate whether the plaintext class is applied or not.
  • addon: It is used to indicate whether the addon is added or not.
  • className: It is used to denote the class name for styling.
  • cssModule: It is used to denote the CSS module for styling.

CustomInput Props:

  • children: It is used to pass the children element to this component.
  • id: It is used to denote the id attribute for the unique identification.
  • type: It is used to denote the type like radio, checkbox, select, etc.
  • label:  It is used for checkbox and radios.
  • inline: It is used to apply the inline class when this is set to true.
  • valid: It is used to apply the is-valid class when this is set to true.
  • invalid: It is used to apply the is-invalid class when this is set to true.
  • bsSize: It is used to denote the bs size like large, small, etc.
  • cssModule: It is used to denote the CSS module for styling.
  • children: It is used to pass the children element to this component.
  • innerRef: It is used to get a reference to the DOM element.

Form Props:

  • children: It is used to pass the children element to this component.
  • inline: It is used to apply the inline class when this is set to true.
  • tag: It is used to pass in custom elements to use.
  • innerRef: It is used to get a reference to the DOM element.
  • className: It is used to denote the class name for styling.
  • cssModule: It is used to denote the CSS module for styling.

FormFeedback Props:

  • children: It is used to pass the children element to this component.
  • tag: It is used to pass in custom elements to use.
  • className: It is used to denote the class name for styling.
  • cssModule: It is used to denote the CSS module for styling.
  • valid: It is used to apply the is-valid class when this is set to true.
  • tooltip: It is used to show the tooltip but the condition is that the parent element must contain the relative position style.

FormGroup Props:

  • children: It is used to pass the children element to this component.
  • row: It is used to apply the row class when this is set to true.
  • check: It is used to apply the form-check class when this is set to true.
  • inline: It is used to apply the inline class when this is set to true.
  • disabled: Applied the disabled class when the check and disabled props are true, does nothing when false.
  • tag: It is used to pass in custom elements to use.
  • className: It is used to denote the class name for styling.
  • cssModule: It is used to denote the CSS module for styling.

FormText Props:

  • children: It is used to pass the children element to this component.
  • inline: It is used to apply the inline class when this is set to true.
  • tag: It is used to pass in custom elements to use.
  • color: It is used to denote the color for this component.
  • className: It is used to denote the class name for styling.
  • cssModule: It is used to denote the CSS module for styling.

Creating React Application And Installing Module:

Step 1: Create a React application using the following command:

npx create-react-app foldername

Step 2: After creating your project folder i.e. foldername, move to it using the following command:

cd foldername

Step 3: After creating the ReactJS application, Install the required module using the following command:

npm install reactstrap bootstrap

Project Structure: It will look like the following.

Project Structure

Example 1: Now write down the following code in the App.js file. Here, we have shown the Form Component without the use of the Col component and row prop.

App.js

 

Step to Run Application: Run the application using the following command from the root directory of the project:

npm start

Output: Now open your browser and go to http://localhost:3000/, you will see the following output:

Example 2: Now write down the following code in the App.js file. Here, we have shown the Form Component with the use of the Col component and row prop.

App.js

 

Step to Run Application: Run the application using the following command from the root directory of the project:

npm start

Output: Now open your browser and go to http://localhost:3000/, you will see the following output:


Last Updated : 07 Mar, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads