react-popper-tooltip

  • Version 4.4.2
  • Published
  • 93.3 kB
  • 3 dependencies
  • MIT license

Install

npm i react-popper-tooltip
yarn add react-popper-tooltip
pnpm add react-popper-tooltip

Overview

React tooltip library built around react-popper

Index

Functions

function usePopperTooltip

usePopperTooltip: (
config?: Config,
popperOptions?: PopperOptions
) => {
state: import('@popperjs/core').State | null;
update: (() => Promise<Partial<import('@popperjs/core').State>>) | null;
forceUpdate: (() => void) | null;
getArrowProps: (args?: PropsGetterArgs) => {
style: React.CSSProperties;
'data-popper-arrow': boolean;
};
getTooltipProps: (args?: PropsGetterArgs) => {
'data-popper-interactive': boolean | undefined;
style: React.CSSProperties;
};
setTooltipRef: React.Dispatch<React.SetStateAction<HTMLElement>>;
setTriggerRef: React.Dispatch<React.SetStateAction<HTMLElement>>;
tooltipRef: HTMLElement | null;
triggerRef: HTMLElement | null;
visible: boolean;
};

    Type Aliases

    type Config

    type Config = {
    /**
    * Whether to close the tooltip when its trigger is out of boundary
    * @default false
    */
    closeOnTriggerHidden?: boolean;
    /**
    * Event or events that trigger the tooltip
    * @default hover
    */
    trigger?: TriggerType | TriggerType[] | null;
    /**
    * Delay in hiding the tooltip (ms)
    * @default 0
    */
    delayHide?: number;
    /**
    * Delay in showing the tooltip (ms)
    * @default 0
    */
    delayShow?: number;
    /**
    * Whether to make the tooltip spawn at cursor position
    * @default false
    */
    followCursor?: boolean;
    /**
    * Options to MutationObserver, used internally for updating
    * tooltip position based on its DOM changes
    * @default { attributes: true, childList: true, subtree: true }
    */
    mutationObserverOptions?: MutationObserverInit | null;
    /**
    * Whether tooltip is shown by default
    * @default false
    */
    defaultVisible?: boolean;
    /**
    * Used to create controlled tooltip
    */
    visible?: boolean;
    /**
    * Called when the visibility of the tooltip changes
    */
    onVisibleChange?: (state: boolean) => void;
    /**
    * If `true`, a click outside the trigger element closes the tooltip
    * @default true
    */
    closeOnOutsideClick?: boolean;
    /**
    * If `true`, hovering the tooltip will keep it open. Normally tooltip closes when the mouse cursor moves out of
    * the trigger element. If it moves to the tooltip element, the tooltip stays open.
    * @default false
    */
    interactive?: boolean;
    /**
    * Alias for popper.js placement, see https://popper.js.org/docs/v2/constructors/#placement
    */
    placement?: PopperJS.Placement;
    /**
    * Shorthand for popper.js offset modifier, see https://popper.js.org/docs/v2/modifiers/offset/
    * @default [0, 6]
    */
    offset?: [number, number];
    };

      type PopperOptions

      type PopperOptions = Partial<PopperJS.Options> & {
      createPopper?: typeof PopperJS.createPopper;
      };

        type PropsGetterArgs

        type PropsGetterArgs = {
        style?: React.CSSProperties;
        [key: string]: unknown;
        };

          type TriggerType

          type TriggerType = 'click' | 'double-click' | 'right-click' | 'hover' | 'focus';

            Package Files (3)

            Dependencies (3)

            Dev Dependencies (35)

            Peer Dependencies (2)

            Badge

            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/react-popper-tooltip.

            • Markdown
              [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/react-popper-tooltip)
            • HTML
              <a href="https://www.jsdocs.io/package/react-popper-tooltip"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>