You can use a Popup to display floating content above the page. Technically, it is a wrapper around Floating UI with some default values. To manage Popup visibility, use the open property.
The Popup child components are rendered inside the Portal component. To disable this behavior, use the disablePortal property.
Use the placement property to manage the Popup position around the anchor element.
By default, Popup uses flip middleware to prevent overflow.
If the property is set to an array, the first element will be used as the default placement value, the rest will be used as fallback placements.
It is also acceptable to use the values auto, auto-start, auto-end to use autoPlacement middleware instead of flip.
Anchor
Top Start
Top
Top End
Right Start
Right
Right End
Bottom End
Bottom
Bottom Start
Left End
Left
Left Start
import{Popup,PopupProps}from'@gravity-ui/uikit';import{CSSProperties, useState}from'react';const anchorStyles:CSSProperties={ margin:'40px 100px', width:320, height:140, border:'2px dashed', display:'flex', alignItems:'center', justifyContent:'center', fontSize:'1.5em',};functionPopupInstance({children,...props}:PopupProps){return(<PopupopendisablePortal{...props}><divstyle={{padding:5}}>{children}</div></Popup>);}exportdefaultfunction(){const[anchorElement, setAnchorElement]=useState<HTMLDivElement |null>(null);return(<div><divref={setAnchorElement}style={anchorStyles}> Anchor</div><PopupInstanceanchorElement={anchorElement}placement="top-start"> Top Start</PopupInstance><PopupInstanceanchorElement={anchorElement}placement="top"> Top</PopupInstance><PopupInstanceanchorElement={anchorElement}placement="top-end"> Top End</PopupInstance><PopupInstanceanchorElement={anchorElement}placement="right-start"> Right Start</PopupInstance><PopupInstanceanchorElement={anchorElement}placement="right"> Right</PopupInstance><PopupInstanceanchorElement={anchorElement}placement="right-end"> Right End</PopupInstance><PopupInstanceanchorElement={anchorElement}placement="bottom-end"> Bottom End</PopupInstance><PopupInstanceanchorElement={anchorElement}placement="bottom"> Bottom</PopupInstance><PopupInstanceanchorElement={anchorElement}placement="bottom-start"> Bottom Start</PopupInstance><PopupInstanceanchorElement={anchorElement}placement="left-end"> Left End</PopupInstance><PopupInstanceanchorElement={anchorElement}placement="left"> Left</PopupInstance><PopupInstanceanchorElement={anchorElement}placement="left-start"> Left Start</PopupInstance></div>);};