Open In App

ReactJS Evergreen Filepicker Component

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

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.

Filepicker Props:

  • 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:

    cd foldername
  • 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.

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 { FilePicker } from 'evergreen-ui'
  
export default function App() {
  
  return (
    <div style={{
      display: 'block', width: 700, paddingLeft: 30
    }}>
      <h4>ReactJS Evergreen FilePicker Component</h4>
  
      <FilePicker
        width={200}
        placeholder="Select your file"
      />
        
    </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://evergreen.segment.com/components/file-picker


Last Updated : 05 Jun, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads