ReactJS Reactstrap Form Component

02 Sep, 2021
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 linline 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 linline 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 linline 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 linline 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 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 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
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
import React from 'react'import 'bootstrap/dist/css/bootstrap.min.css';import {    FormGroup, Label, Input,    Button, Form} from 'reactstrap';  function App() {      return (        <div style={{            display: 'block', width: 550, padding: 30        }}>            <h5>ReactJS Reactstrap Form Component</h5>            <Form>                <FormGroup>                    <Label for="emailField">EMAIL:</Label>                    <Input type="email" name="email" id="emailField"                        placeholder="Enter your email" />                </FormGroup>                <FormGroup>                    <Label for="passwordField">PASSWORD:</Label>                    <Input type="password" name="password"                         id="passwordField"                        placeholder="Enter your password" />                </FormGroup>                <Button>Submit</Button>            </Form>        </div >    );}  export default App;
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
import React from 'react'import 'bootstrap/dist/css/bootstrap.min.css';import {    FormGroup, Label, Input,    Button, Form, Col} from 'reactstrap';  function App() {      return (        <div style={{            display: 'block', width: 950, padding: 30        }}>            <h5>ReactJS Reactstrap Form Component</h5>            <Form inline>                <FormGroup row className="mb-2 mr-sm-2 mb-sm-0">                    <Col sm={4}>                        <Label for="emailField">EMAIL:</Label>                        <Input type="email" name="email" id="emailField"                            placeholder="Enter your email" />                    </Col>                    <Col sm={4}>                        <Label for="passwordField">PASSWORD:</Label>                        <Input type="password" name="password"                             id="passwordField"                            placeholder="Enter your password" />                    </Col>                </FormGroup>                <Button>Submit</Button>            </Form>        </div >    );}  export default App;
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:
Reference: https://reactstrap.github.io/components/form/
clintra
Reactstrap
JavaScript
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
Roadmap to Learn JavaScript For Beginners
JavaScript | Promises
How to fetch data from an API in ReactJS ?
How to redirect to another page in ReactJS ?
Axios in React: A Guide for Beginners
ReactJS Functional Components