Component API
This is the list of props that you should probably know about👇
#
trigger{node,func} | require
Element to be rendered in-place where the popup is defined
// need to forward ref if you are trying to use a function trigger with React Component
// Works<Popup trigger={open => ( <button className="button">Trigger - {open ? 'Opened' : 'Closed'}</button> )} position="right center" closeOnDocumentClick> <span> Popup content </span></Popup>;
// works tooconst CustomButton = React.forwardRef(({ open, ...props }, ref) => ( <button className="button" ref={ref} {...props}> Trigger - {props.open ? 'Opened' : 'Closed'} </button>));
<Popup trigger={open => <CustomButton open={open} />} position="right center" closeOnDocumentClick> <span> Popup content </span></Popup>;
#
open{bool}
Take full control over the popup state.
#
defaultOpenbool | false
Default open value : initial state
#
onenum,Array |
'hover'
Events triggering the popup. Enums or Array of : 'hover' 'click' 'focus' 'right-click'
.
#
childrennode or func
Popup content
#
position{enum, Array} |
'bottom center'
Position for the popover. Best position(calculated by checking against overlap with boundary element) is applied in the order specified.
Enums:'top left' 'top right' 'bottom right' 'bottom left' 'right center' 'left center' 'top center' 'bottom center' 'center center'
#
offsetXnumber | 0
OffsetX in pixels to be applied to the Popup.
#
offsetYnumber | 0
OffsetY in pixels to be applied to the Popup.
#
arrowbool | true
Arrow element. Note that this should be set to false
if the position is set to 'center center'
#
modalbool| false
A modal component when modal ={true}
#
disabledbool | false
Disable the popup from showing up and close it if it's open
#
lockScrollbool | false
Disable body scroll when modal is open ( work only with modal)
#
closeOnDocumentClickbool | true
Close popup when the overlay clicked
#
closeOnEscapebool | true
Close popup when Escape clicked
#
repositionOnResizebool | true
Recalculate position when window
is resized
#
mouseEnterDelaynumber | 100 Milliseconds to wait before opening on mouse over
#
mouseLeaveDelaynumber | 100
Milliseconds to wait before closing on mouse leave
#
onOpenfunc
A function called on open event
#
onClose{func}
A function called on close event
#
contentStyleobject
Custom popup content style |
#
overlayStyleobject
Custom overlay style
Note: top
and left
property will not be overridden. |
#
arrowStyleobject
Custom arrow style
Note: transform
property will not be overridden. |
#
classNamestring
Custom Popup ClassName
Note: this class name will be merged with the component element: ex className='foo'
means foo-arrow
to style arrow, foo-overlay
to style overlay and foo-content
to style popup content |
#
keepTooltipInsidebool, string | true
Html selector, class name or id element that the tooltip must be inside (defaults to window
if keepTooltipInside = true) default false |
#
nestedbool | false
Starting from v2 you should add nested props if you are going to use nested popups ( to make sure onClickOutside
behavior will work as expected)