Skip to content
Related Articles

Related Articles

Improve Article

React Suite Form Component

  • Last Updated : 20 Jun, 2021
Geek Week

React Suite is a popular front-end library with a set of React components that are designed for the middle platform and back-end products. Form Component provides a way to make a form and take user input and then forward it to the server for further data processing. We can use the following approach in ReactJS to use the React Suite Form Component.

Form Props:

  • checkDelay: It is used to delay the processing when data check.
  • checkTrigger: It is used to denote the form validation trigger type.
  • classPrefix: It is used to denote the prefix of the component CSS class.
  • errorFromContext: It is used to denote that the error reminders in FormControl default from Context.
  • fluid: It allows the input 100% of the form to fill the container.
  • formDefaultValue: It is used to denote the default value of the form.
  • formError: It is used for the error message of the form.
  • formValue: It is used to denote the value of form (Controlled).
  • layout: It is used to set the left and right columns of the layout of the elements within the form.
  • model: It is used to denote the SchemaModel Object.
  • onChange: It is a callback function that is triggered when data changing.
  • onCheck: It is a callback function that is triggered when data checking.
  • onError: It is a callback function that is triggered when error checking.

Form Methods:

  • check: This method is used to Verify form data.
  • checkAsync: It is an asynchronous function to check form data.
  • checkForField: This method is used to Checklist single field value.
  • checkForFieldAsync: It is an asynchronous function to check form single field value.
  • cleanErrors: This method is used to clean error message.
  • cleanErrorForFiled: This method is used to clear a single field error message.

FormControl Props:

  • accepter: It is used to denote the proxied components.
  • checkTrigger: It is used to denote the data validation trigger type.
  • classPrefix: It is used to denote the prefix of the component CSS class.
  • errorMessage: It is used to show error messages.
  • errorPlacement: It is used for the placement of error messages.
  • name: It is used to denote the name of form-control.
  • readOnly: It is used to make the control readonly.
  • plaintext: It is used to make the control plaintext.

 



FormGroup Props:

  • classPrefix: It is used to denote the prefix of the component CSS class.
  • controlId: It is used to set the id for the controlled component.

ControlLabel Props:

  • classPrefix: It is used to denote the prefix of the component CSS class.
  • htmlFor: It is used to denote the attribute of the HTML label tag.
  • srOnly: It is used for the screen reader only.

HelpBlock Props:

  • classPrefix: It is used to denote the prefix of the component CSS class.
  • htmlFor: It is used to denote the attribute of the HTML label tag.
  • tooltip: It is used to indicate whether to show through the Tooltip component or not.

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 rsuite

Project Structure: It will look like the following.



Project Structure

Example: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.

App.js




import React from 'react'
import 'rsuite/dist/styles/rsuite-default.css';
import {
  Form, FormGroup, FormControl, Button,
  ControlLabel,
} from 'rsuite';
  
export default function App() {
  
  return (
    <div style={{
      display: 'block', width: 700, paddingLeft: 30
    }}>
      <h4>React Suite Form Component</h4>
      <Form>
        <FormGroup>
          <ControlLabel>Enter your Email:</ControlLabel>
          <FormControl name="email" type="email" />
        </FormGroup>
        <FormGroup>
          <ControlLabel>Enter your Password:</ControlLabel>
          <FormControl name="password" type="password" />
        </FormGroup>
        <FormGroup>
          <Button appearance="primary">Login</Button>
        </FormGroup>
      </Form>
    </div>
  );
}

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://rsuitejs.com/components/form/

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it’s lowest price ever!




My Personal Notes arrow_drop_up
Recommended Articles
Page :