Set a custom position
I believe that this is one of the nicest feature of the library. I've used this feature to build the demo dropdown's.
When you display the menu you can provide x
and y
coordinates
import { useContextMenu } from "react-contexify";
function App() {
const { show } = useContextMenu({ id: "menuId" });
function displayMenu(e) {
show({
event: e,
position: {
x: 100,
y: 10,
},
});
}
return <div onContextMenu={displayMenu}>Hello</div>;
}