Open In App

React.js Blueprint Popover2 Props

Blueprint is a React-based UI toolkit for the web. This library is very optimized and popular for building interfaces that are complex and data-dense for desktop applications.

In this article, we’ll discuss React.js Blueprint Popover2 Props. Popovers help in displaying the floating content next to the target element. The various props of Popover2 are given below.



React.js BluePrint Popover2 Props:

 



Syntax:

<Popover2
      ...
    <Button
        text="Click"
    />
      )}
/>

Creating React Application And Installing Module:

Step 1: Create a React application using the following command:

npm create-react-app appname

Step 2: After creating your project folder i.e. appname, move to it using the following command:

cd appname

Step 3: After creating the ReactJS application, Install the required module using the following command:

npm install @blueprintjs/core

Project Structure:

 

Example 1: The below example demonstrates the usage of minimal, content, and renderTarget props of popover2.




import React from "react";
import "@blueprintjs/core/lib/css/blueprint.css";
import { Button } from "@blueprintjs/core";
import { Popover2 } from "@blueprintjs/popover2";
import "@blueprintjs/popover2/lib/css/blueprint-popover2.css";
  
function App() {
    return (
        <center>
            <div style={{ 
                padding: 20, 
                textAlign: "center"
                color: "green" 
            }}>
                <h1>GeeksforGeeks</h1>
                <h2>ReactJS BluePrint Popover2 Props</h2>
            </div>
            <Popover2
                position="bottom"
                content={
                    <div style={{ 
                        backgroundColor: "pink"
                        padding: 5 
                    }}>
                        <h4>Are you sure you want to Delete?</h4>
                    </div>
                }
                renderTarget={({ isOpen, ref, 
                    ...targetProps }) => (
                    <Button
                        {...targetProps}
                        elementRef={ref}
                        text="Delete"
                        intent="danger"
                    />
                )}
            />
        </center>
    );
}
  
export default App;

Output:

 

Example 2: The below example demonstrates the usage of interactionKind, placement, and transitionDuration props of popover2.




import React from "react";
import "@blueprintjs/core/lib/css/blueprint.css";
import { Button } from "@blueprintjs/core";
import { Popover2 } from "@blueprintjs/popover2";
import "@blueprintjs/popover2/lib/css/blueprint-popover2.css";
  
function App() {
    return (
        <center>
            <div style={{ 
                padding: 20, 
                textAlign: "center"
                color: "green" 
            }}>
                <h1>GeeksforGeeks</h1>
                <h2>ReactJS BluePrint Popover2 Props</h2>
            </div>
            <Popover2
                interactionKind="hover"
                placement="auto"
                transitionDuration={500}
                content={
                    <div>
                        <h4>Confirm Delete?</h4>
                    </div>
                }
                renderTarget={({ isOpen, ref, 
                    ...targetProps }) => (
                    <Button
                        {...targetProps}
                        elementRef={ref}
                        text="Delete"
                        intent="danger"
                    />
                )}
            />
        </center>
    );
}
  
export default App;

Output:

 

Note: In the above output, the popover popups after hovering over the button not by clicking.

Reference: https://blueprintjs.com/docs/#popover2-package/popover2.props


Article Tags :