ReactJS Blueprint Popover Component - GeeksforGeeks

08 Apr, 2022
BlueprintJS is a React-based UI toolkit for the web. This library is very optimized and popular for building interfaces that are complex data-dense for desktop applications.
Popover Component provides a way for users to display floating content next to a target element. We can use the following approach in ReactJS to use the ReactJS Blueprint Popover Component.
Popover Props:
autoFocus: It is used to indicate whether the overlay should acquire application focus when it first opens.
backdropProps: It is used to denote the HTML props for the backdrop element.
boundary: It is used to denote a boundary element supplied to the flip and preventOverflow modifiers.
canEscapeKeyClose: It is used to indicate whether pressing the ESC key should invoke onClose.
captureDismiss: When a user clicks inside a Classes.POPOVER_DISMISS element will only close the current popover and not the outer popovers when this prop is enabled.
className: It is used to denote a space-delimited list of class names to pass along to a child element.
content: It is used to denote the content that will be displayed inside the popover.
defaultIsOpen: It is used to denote the initial opened state when uncontrolled.
disabled: It is used to prevent the popover from appearing when true.
enforceFocus: It is used to indicate whether the overlay should prevent focus from leaving itself.
fill: It is used to indicate whether the wrapper and target should take up the full width of their container.
hasBackdrop: It is used to enable an invisible overlay beneath the popover that captures clicks and prevents interaction with the rest of the document until the popover is closed.
hoverCloseDelay: It is used to denote the amount of time in milliseconds the popover should remain open after the user hovers off the trigger.
hoverOpenDelay: It is used to denote the amount of time in milliseconds the popover should wait before opening after the user hovers over the trigger.
inheritDarkTheme: It is used to indicate whether a popover that uses a Portal should automatically inherit the dark theme from its parent.
interactionKind: It is used to denote the kind of hover interaction that triggers the display of the popover.
isOpen: It is used to indicate whether the popover is visible.
lazy: The Portal containing the children is created and attached to the DOM when the overlay is opened for the first time when this is set to true and usePortal is true.
minimal: It is used to indicate whether to apply minimal styling to this popover.
modifiers: It is used to override for Popper.js built-in modifiers.
onClose: It is a callback that is triggered when user interaction causes the overlay to close.
onClosed: It is used to denote a lifecycle method invoked just after the CSS close transition ends but before the child has been removed from the DOM.
onClosing: It is used to denote a lifecycle method invoked just before CSS close transition begins on a child.
onInteraction: It is a callback function that is triggered in controlled mode when the popover open state would change due to user interaction.
onOpened: It is used to denote a lifecycle method invoked just after the CSS open transition ends.
onOpening: It is used to denote a lifecycle method invoked just after mounting the child in the DOM but just before the CSS open transition begins.
openOnTargetFocus: It is used to indicate whether the popover should open when its target is focused.
placement: It is used to denote the placement at which the popover should appear.
popoverClassName: It is used to denote a space-delimited string of class names applied to the popover element.
popoverRef: It is used to pass the ref supplied to the Classes.POPOVER element.
portalClassName: It is used to denote a space-delimited string of class names applied to the Portal element if usePortal is true.
portalContainer: It is used to denote the container element into which the overlay renders its contents when usePortal is true.
position: It is used to denote the position at which the popover should appear. Mutually exclusive with placement prop.
positioningStrategy: It is used for the Popper.js positioning strategy.
renderTarget: It is used to denote the target renderer which receives props injected by Popover which should be spread onto the rendered element.
rootBoundary: It is used to denote a root boundary element supplied to the flip and preventOverflow modifiers.
targetTagName: It is used to denote the HTML tag name for the target element.
transitionDuration: It is used to indicate how long the popover appears/disappears transition takes in milliseconds.
usePortal: It is used to indicate whether the popover should be rendered inside a Portal attached to portalContainer prop.
wrapperTagName: It is used to denote the HTML tag name for the wrapper element, which also receives the className prop.
 
Creating React Application And Installing Module:
Step 1: Create a React application using the following command:npx create-react-app foldername
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 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 @blueprintjs/core
npm install @blueprintjs/core
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 '@blueprintjs/core/lib/css/blueprint.css';import { Button, H3, Popover } from "@blueprintjs/core";  function App() {      return (        <div style={{            display: 'block', width: 400, padding: 30        }}>            <h4>ReactJS Blueprint Popover Component</h4>            <br></br><br></br><br></br>            <Popover content={<H3>Sample Popover Content!</H3>}>                <Button text="Click to Open Popover" />            </Popover>        </div >    );}  export default App;
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://blueprintjs.com/docs/#core/components/popover
Blueprint-Core
Blueprint-Overlays
React-Blueprint
JavaScript
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to get character array from string in JavaScript?
How to fetch data from an API in ReactJS ?
How to redirect to another page in ReactJS ?
How to pass data from child component to its parent in ReactJS ?
How to pass data from one component to other component in ReactJS ?
ReactJS Functional Components