useTootip

useTooltip is a hook for building a tooltip.

The tooltip pattern in ARIA practices is still under development, and there is an ongoing discussion about the role's purpose.

This follows that pattern and the pattern used on Slack.

Usage

const { props, tooltip } = useTooltip('Tooltip message');

return (
  <>
    <button type="button" {...props}>
      Action
    </button>
    {tooltip}
  </>
);

Arguments

{ props, tooltip } = useTooltip(message, { id, positionOptions, className = 'react-dialogs-tooltip', ...props })

Returns: