Skip to content

Latest commit

 

History

History
68 lines (56 loc) · 1.48 KB

README.md

File metadata and controls

68 lines (56 loc) · 1.48 KB

React Overlay Trigger

Tiny and simple popover library for React

npm version npm bundle size

Checkout Website for more details.

Installation

npm i -S react-overlay-trigger

Usage

import { usePopover } from 'react-overlay-trigger'

const App = () => {
  const { popover, triggerProps } = usePopover({
    placement: 'top',
    hoverToggle: true,
  })

  return (
    <div>
      {popover}
      <button {...triggerProps}>hover me</button>
    </div>
  )
}

API

usePopover(
  popover: ReactNode,
  options: {    
    clickToggle?: boolean
    hoverToggle?: boolean
    focusToggle?: boolean
    container?: HTMLElement
    placement: PlacementType
    arrowProps?: { size: number }
    defaultOpen?: boolean
    delayDuration?: number
  }
): {
  popover: ReactNode
  isOpen: boolean
  triggerProps: {
    ref: RefCallback<any>
    onMouseEnter?: (e: MouseEvent) => void
    onMouseLeave?: (e: MouseEvent) => void
    onPointerEnter?: (e: PointerEvent) => void
    onPointerLeave?: (e: PointerEvent) => void
    onFocus?: (e: FocusEvent) => void
    onBlur?: (e: FocusEvent) => void
    onClick?: (e: MouseEvent) => void
  }
}

License

MIT