useClick
Opens or closes the floating element when clicking the reference element.
Usage
Options
enabled | Whether the Hook is enabled, including all internal Effects and event handlers. |
event | The type of event to use to determine a "click" with mouse input. Keyboard clicks work as normal. |
toggle | Whether to toggle the open state with repeated clicks. |
ignoreMouse | Whether to ignore the logic for mouse input (for example, if `useHover()` is also being used). When `useHover()` and `useClick()` are used together, clicking the reference element after hovering it will keep the floating element open even once the cursor leaves. This may not be desirable in some cases. |
keyboardHandlers | Whether to add keyboard handlers (Enter and Space key functionality) for non-button elements (to open/close the floating element via keyboard "click"). |
Compare
Compare to Floating UI React.