@maktouch/use-popper
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

Use Popper

npm npm NpmLicense

Installation

Note: React 16.8+ is required for Hooks.

With npm

npm i use-popper

Or with yarn

yarn add use-popper

Edit usePopper

import React from 'react';
import usePopper from 'use-popper';
import { useHover } from 'use-events';

function Tooltip(props) {
  const { referrence, popper, arrow } = usePopper({ placement: 'bottom' });
  const [active, bind] = useHover();

  return (
    <div>
      <button ref={referrence.ref} {...bind}>
        hover me
      </button>
      {active && (
        <div
          ref={popper.ref}
          style={popper.styles}
          data-placement={popper.placement}
        >
          <div>Hello!</div>
          <div ref={arrow.ref} style={arrow.styles} />
        </div>
      )}
    </div>
  );
}

export default Tooltip;

Readme

Keywords

none

Package Sidebar

Install

npm i @maktouch/use-popper

Weekly Downloads

0

Version

1.3.0

License

MIT

Unpacked Size

17 kB

Total Files

15

Last publish

Collaborators

  • maktouch