Skip to main content

parent

Description

Optional. An HTML element relative to which the popup will be positioned

Usage

parent?: HTMLElement;

Example

function Example() {
const nodeRef = useRef<HTMLElement | null>(null);
const [isOpen, setIsOpen] = useState(false);
const showPopup = () => setIsOpen(true);

return (
<div ref={nodeRef}>
<Button type="block" onClick={showPopup}>Show next to button</Button>

{isOpen && (
<Popup parent={nodeRef.current}>
<p>Some text</p>
</Popup>
)}
</div>
);
}