Open In App

React Suite Popover Component

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. Popover Component allows the user to show the popup information that is trigger on some event over the parent window. We can use the following approach in ReactJS to use the React Suite Popover Component.

Popover Props:



Whisper Props:

Whisper Methods:



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

 

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

In this example, we have learnt to use a Dropdown menu as a Popover




import React from 'react'
import 'rsuite/dist/rsuite.min.css';
import { Popover, Whisper, Button } from 'rsuite';
import { Dropdown } from 'rsuite';
 
export default function App() {
 
  return (
    <div style={{
      display: 'block', width: 600, paddingLeft: 30
    }}>
    <h1 style={{color:'green'}}>GeeksforGeeks</h1>
      <h4>React Suite Popover Component</h4> <br></br>
      <Whisper
        trigger="click"
        placement='bottom'
        speaker={
          <Popover title="Geeks Menu">
          <Dropdown.Menu >
          <Dropdown.Item >New File</Dropdown.Item>
          <Dropdown.Item >New File with Current Profile</Dropdown.Item>
          <Dropdown.Item>Download As...</Dropdown.Item>
          <Dropdown.Item >Export PDF</Dropdown.Item>
          
        </Dropdown.Menu>
          </Popover>
        }
      >
        <Button appearance="subtle">
          Click me to Open Popover
        </Button>
      </Whisper>
    </div>
  );
}

 

OUTPUT

 

Reference: https://rsuitejs.com/components/popover/


Article Tags :