The usePosition
hook allows one to position an element relative to another
element.
See the <Popover>
component for a real-world example.
Usage
import { usePosition } from "@artsy/palette"
const ToolTip = (props) => {
const { anchorRef, tooltipRef } = usePosition({
position: "top-start",
offset: 10,
active: true,
})
return (
<Box ref={anchorRef}>
<Box ref={tooltipRef}>Positioned</Box>
</Box>
)
}