Skip to content
Related Articles

Related Articles

ReactJS Evergreen SideSheet Component

Improve Article
Save Article
Like Article
  • Last Updated : 11 Jun, 2021

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. SideSheet Component allows the user to show more details about an object. We can use the following approach in ReactJS to use the Evergreen SideSheet Component.

SheetClose Props:

  • isClosing: It is used for indicating the close behavior of this component.
  • position: It is used for the position of the component.

SideSheet Props:

  • children: The children can be a string, a function, or a node.
  • isShown: It is used to show the SideSheet when this is set to true.
  • onCloseComplete: It is a function that will be triggered when the exit transition is complete.
  • onOpenComplete: It is a function that will be triggered when the enter transition is complete.
  • onBeforeClose: It is a function that is called when the overlay is about to close.
  • shouldCloseOnOverlayClick: It is used to indicate whether overlay should close the overlay on click or not.
  • shouldCloseOnEscapePress: It is used to indicate whether pressing ESC key should close the overlay or not.
  • width: It is used to define the width of the SideSheet.
  • containerProps: It is used to define the properties to pass through the SideSheet container Pane.
  • position: It is used to position the sheet.
  • preventBodyScrolling: It is used to indicate whether to prevent scrolling in the outer body 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 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 { SideSheet, Button } from 'evergreen-ui'
  
export default function App() {
  
  const [sideSheetOpenStatus, setSideSheetOpenStatus] = React.useState(false)
  
  return (
    <div style={{
      display: 'block', width: 700, paddingLeft: 30
    }}>
      <h4>ReactJS Evergreen SideSheet Component</h4>
      <React.Fragment>
        <SideSheet
          isShown={sideSheetOpenStatus}
          onCloseComplete={() => setSideSheetOpenStatus(false)}
        ><h4>Sample Text for this Component!</h4>
        </SideSheet>
        <Button
          onClick={() => setSideSheetOpenStatus(true)}
        >Open SideSheet</Button>
      </React.Fragment>
    </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/side-sheet


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!