ReactJS Evergreen Filepicker Component
React Evergreen is a popular front-end library with a set of React components for building beautiful products as this library is flexible, sensible defaults, and User friendly. Filepicker Component allows the user to select one or multiple files from the file system. We can use the following approach in ReactJS to use the Evergreen Filepicker Component.
- name: It is used to denote the name attribute of the input.
- accept: It is used to denote the accept attribute of the input.
- required: It is used to make the Filepicker required when true.
- multiple: It is used to accept multiple files when true.
- disabled: It is used to disable the Filepicker when this is set to true.
- capture: It is used to denote the capture attribute of the input.
- height: It is used to denote the height of the file picker.
- onChange: It is a function that is called when onChange is fired.
- onBlur: It is a function that is called when onBlur is fired.
- placeholder: It is used to denote the placeholder of the text input.
- className: It is used to pass the class name for the Filepicker.
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:
Step 3: After creating the ReactJS application, Install the required module using the following command:
npm install evergreen-ui
Project Structure: It will look like the following.
Example: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
Step to Run Application: Run the application using the following command from the root directory of the project:
Output: Now open your browser and go to http://localhost:3000/, you will see the following output: