use Click
Opens or closes the floating element when clicking the reference element.
Usage
This Hook returns event handler props.
To use it, pass it the context
object returned from
useFloating()
, and then feed its result into the
useInteractions()
array. The returned prop getters are
then spread onto the elements for rendering.
Props
enabled
default: true
Conditionally enable/disable the Hook.
event
default: 'click'
The type of event to use to determine a “click” with mouse input. Keyboard clicks work as normal.
toggle
default: true
Whether to toggle the open state with repeated clicks.
ignoreMouse
default: false
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 be
not be desirable in some cases.
keyboardHandlers
default: true
Whether to add keyboard handlers (Enter
and Space
key
functionality) for non-button elements (to open/close the
floating element via keyboard “click”).