Skip to content
This repository has been archived by the owner on Mar 31, 2021. It is now read-only.

Latest commit

 

History

History
43 lines (37 loc) · 892 Bytes

README.md

File metadata and controls

43 lines (37 loc) · 892 Bytes

react-popper-tooltip-hook

Experimenting with possible hook API for react-popper-tooltip.

Updated: Eventually it was released as react-popper-tooltip version 4.

Codesandbox.

const {
  arrowRef,
  tooltipRef,
  triggerRef,
  getArrowProps,
  getTooltipProps,
  setArrowRef,
  setTooltipRef,
  setTriggerRef,
  visible,
  ...popperProps
} = usePopperTooltip(config, popperOptions);
<>
  <button type="button" ref={setTriggerRef}>
    Reference element
  </button>

  {visible && (
    <div
      ref={setTooltipRef}
      {...getTooltipProps({ className: "tooltip-container" })}
    >
      Popper element
      <div
        ref={setArrowRef}
        {...getArrowProps({ className: "tooltip-arrow" })}
      />
    </div>
  )}
</>