Skip to main content

Popup

We need the popup component in many places, with this package you get a nice popup component without any hassle.

Example Usage

import { Popup, Button } from "react-chat-elements"

const [show, setShow] = React.useState(false);

<Button text={"Show Result"} onClick={() => setShow(true)} />

const popup = {
show:show,
header:"Example Popup",
headerButtons: [
{
type: "transparent",
color: "black",
text: "X",
onClick: () => {
setShow(false);
},
},
],
text:"Here is a sample popup component to use in your projects.",
footerButtons: [
{
color: "white",
backgroundColor: "#ff5e3e",
text: "Cancel",
onClick: () => {
setShow(false);
},
},
{
color: "white",
backgroundColor: "lightgreen",
text: "OK",
onClick: () => {
setShow(false);
},
},
]
}

<Popup
popup={popup}
/>

Result

propdefaulttypedescription
popupnoneobjectpopup data (see details below)
typenonestringpopup type
classNamenonestringclassName for optional className
propdefaulttypedescription
showfalseboolpopup visible
headernonestringpopup title (header) message
headerButtonsnonearraypopup title (header) buttons (see details below)
textnonestringpopup content (center) message
color#333string (color)popup content message color
footerButtonsnonearraypopup footer buttons (see details below)
renderHeadernonefunction (component)render header function
renderContentnonefunction (component)render content function
renderFooternonefunction (component)render footer function
propdefaulttypedescription
typenonestringpopup header type
colornonestringpopup header color
onClicknonefunctionpopup header onClick event
iconnoneobjectpopup header icon (see details below)
propdefaulttypedescription
size12numberpopup header icon font size
componentnoneReactChildpopup header icon component
propdefaulttypedescription
textnonestringpopup footer text
colornonestringpopup footer color
onClicknonefunctionpopup footer onClick event
backgroundColornonestringpopup footer background color