ReactJS Blueprint Popover Component
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.
- 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 2: After creating your project folder i.e. foldername, move to it using the following command:
- Step 3: After creating the ReactJS application, Install the required module using the following command:
npm install @blueprintjs/core
Project Structure: It will look like the following.
Example: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
Step to Run Application: Run the application using the following command from the root directory of the project:
Output: Now open your browser and go to http://localhost:3000/, you will see the following output:
We will use Blueprint popover with a Dropdown menu . Also we will learn to change placement of the popover.
Please Login to comment...