Tiny and simple popover library for React
Checkout Website for more details.
npm i -S react-overlay-trigger
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>
)
}
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
}
}
MIT