A tooltip component to display contextual messages.

Parameters:
NameTypeDescription
propsobject

Component props.

Properties
NameTypeDescription
buffernumber

The buffer from the edge of the window, in px.

childrenJSX.Element

React element children.

contentstring

Tooltip content. Can only be strings. Use React children for html.

contentAttributesobject

Attributes for the tooltip content text component.

customAttributesobject

Custom attributes for the component.

customClassesstring | Array | object

Custom classes for the component.

iconstring

The name for the icon to use from the Gform admin icon library.

iconPrefixstring

The prefix for the icon class.

iconPresetstring

The preset for the icon (optional).

intentDelaynumber

The delay to detect intent before the tooltip displays, in ms.

idstring

The id for the tooltip. If not passed auto generated using uniqueId from our utils with a prefix of tooltip.

maxWidthnumber

The max width of the tooltip, in px.

positionstring

The position of the tooltip, one of top, right, bottom, or left.

spacingstring | number | Array | object

The spacing for the component, as a string, number, array, or object.

tagNamestring

The tag to use for the tooltip. Defaults to div.

themestring

The theme of the tooltip, one of chathams or port.

tooltipCustomAttributesobject

Custom attributes for the tooltip.

typestring

The type of the tooltip button, one of default, success, or error.

refobject | null

Ref to the component.

Since
  • 1.1.15
Returns:

Return the functional tooltip component in React.

Type: 
JSX.Element
Example
import Tooltip from '@gravityforms/components/react/admin/modules/Tooltip';

return (
     <Tooltip customClasses={ [ 'example-class' ] } maxWidth={ 200 }>
         { children }
     </Tooltip>
);

Methods

(inner) TooltipContent(con, cAttributes) → {JSX.Element|null}

The tooltip content if content exists, otherwise null.

Parameters:
NameTypeDescription
constring

Tooltip content. Can only be strings.

cAttributesobject

Custom attributes for the tooltip content.

Returns:
Type: 
JSX.Element | null

(inner) getNewPositionPercentageInFrame(from, to, rect, frame, bf) → {number}

Get the new position percentage in frame from the old position.

Parameters:
NameTypeDescription
fromstring

Initial position of rect, one of top, bottom, left, or right.

tostring

Final position of rect, one of top, bottom, left, or right.

rectDOMRect

The DOMRect object of rect.

frameWindow

The DOM element of the frame.

bfnumber

The buffer from the edge of the frame, in px.

Returns:

The new position percentage in frame.

Type: 
number

(inner) getPercentageInFrame(w, h, offsetLeft, offsetRight, offsetTop, offsetBottom) → {number}

Get the percentage of an area that is within frame, whether the box area is defined by width and height.

Parameters:
NameTypeDescription
wnumber

The width of the box.

hnumber

The width of the box.

offsetLeftnumber

The left offset of the box, which is subtracted from the box area.

offsetRightnumber

The right offset of the box, which is subtracted from the box area.

offsetTopnumber

The top offset of the box, which is subtracted from the box area.

offsetBottomnumber

The bottom offset of the box, which is subtracted from the box area.

Returns:

The percentage of the box area that is within frame, as a decimal.

Type: 
number

(inner) getSmartPosition(bf, pos, tRef) → {string}

Get smart position based on area in the frame.

Parameters:
NameTypeDescription
bfnumber

The buffer from the edge of the frame, in px.

posstring

The current position of the tooltip.

tRefobject

The ref object of the tooltip.

Returns:

The smart position based on area.

Type: 
string