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).
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”).
stickIfOpen
default: true
If already open from another event such as the useHover()
Hook, determines whether to keep the floating element open when
clicking the reference element for the first time.