1. Third-Party Package reactjs-popup
NPM contains a reactjs-popup, a third-party package to display popup in your application.
It provides a React component that helps you create simple and complex Modals, Tooltips, and Menus for your application.
Installation Command:
1.1 Advantages
- ReactJS provides Modal, Tooltip, and Menu
- Provides Support for controlled Modals & Tooltips
2. ReactJS Popup Props
We can provide different props to the ReactJS Popup component. Below are some of the most commonly used props.
Prop | Description | Default Value |
---|---|---|
trigger | Represents the element to be rendered in-place where the Popup is defined | JSX element |
modal | When set to true, Popup content will be displayed as a modal on the trigger of Popup. If not tooltip will be displayed | false |
position | Defines the position of the tooltip. It can be one of 'top left', 'top right', 'bottom right', 'bottom left' | bottom center |
open | Defines the state of Popup. Whether it is opened or not | false |
overlayStyle | Custom overlay style | object |
2.1 trigger Prop
File: src/components/ReactPopup/index.js
JSX
File: src/components/ReactPopup/index.css
CSS
File: src/App.js
JSX
Note
The value of the trigger prop should be a JSX element.
2.2 modal Prop
File: src/components/ReactPopup/index.js
JSX
2.3 modal Prop with close button
File: src/components/ReactPopup/index.js
JSX
2.4 position Prop
File: src/components/ReactPopup/index.js
JSX
2.5 overlayStyle Prop
File: src/components/ReactPopup/index.js
JSX