Replies: 4 comments 16 replies
-
Looks like there's no way to access the internal state of the Menu at least. No way to open it to activate the FocusTrap and no way to have it close when you click outside. So I will have to implement both myself... It's a real shame that nobody can seem to figure out how to use this library to achieve a simple context menu. I wish the building blocks of headlessui were separate packages so I could make my own components with keybinds and focustraps and whatnot, but those are all completely private implementation details because of course they are. |
Beta Was this translation helpful? Give feedback.
-
Headless UI mention positioning their Popover component using Popper JS, see https://headlessui.com/react/popover#positioning-the-panel In turn, Popper has "virtual elements" which can be used as popper targets. Combine the knowledge of these two to achieve your goal. |
Beta Was this translation helpful? Give feedback.
-
You can just put a React ref on the |
Beta Was this translation helpful? Give feedback.
-
I know this is not related to Headless UI, but do check out Radix UI's Context Menu as an alternative, it is fully accessible. I switched from Headless UI to Radix UI ever since, because Radix UI have much more components to work with. :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I'm just getting started with React and Headless UI, and I'm not sure which Headless UI component would be best for a right-click menu. Perhaps Menu or Popover? Are there any good libraries to help with this as well?
Beta Was this translation helpful? Give feedback.
All reactions