What's new webinar: AG Grid 36 and AG Charts 14 Join us for a webinar on 14th July at 2pm UTC+1 Register




Core Features

Advanced Features

React Data GridTooltips

Tooltips can be set for Cells and Column Headers.

The following Column Definition properties set Tooltips:

tooltipFieldCopy Link
ColDefField
The field of the tooltip to apply to the cell. When the column is grouped, group rows in the generated group column inherit this value.
tooltipValueGetterCopy Link
TooltipValueGetterFunc
Callback that should return the string to use for a tooltip, tooltipField takes precedence if set. If using a custom tooltipComponent you may return any custom value to be passed to your tooltip component. When the column is grouped, group rows in the generated group column inherit this callback.

Tooltips for Truncated Text Copy Link

It's possible to configure tooltips to show only when the items hovered are truncated by setting tooltipShowMode = 'whenTruncated'.

tooltipShowMode = 'whenTruncated' has no effect when using Browser Tooltips, as Browser Tooltips are controlled by the browser and not the grid.

Show and Hide Delay Copy Link

By default, tooltips show after 2 seconds and hide after 10 seconds. These delays can be configured in milliseconds:

tooltipShowDelayCopy Link
number
default: 2000
The delay in milliseconds that it takes for tooltips to show up once an element is hovered over. Note: This property does not work if enableBrowserTooltips is true.
tooltipSwitchShowDelayCopy Link
number
default: 200
The delay in milliseconds before a tooltip is shown when moving the pointer from one tooltip-enabled element to another while the previous tooltip is still visible or pending hide. Note: This property does not work if enableBrowserTooltips is true.
tooltipHideDelayCopy Link
number
default: 10000
The delay in milliseconds that it takes for tooltips to hide once they have been displayed. Note: This property does not work if enableBrowserTooltips is true and tooltipHideTriggers includes timeout.
const tooltipShowDelay = 0;
const tooltipSwitchShowDelay = 1000;
const tooltipHideDelay = 2000;

<AgGridReact
    tooltipShowDelay={tooltipShowDelay}
    tooltipSwitchShowDelay={tooltipSwitchShowDelay}
    tooltipHideDelay={tooltipHideDelay}
/>

Setting delays will have no effect if using Browser Tooltips as Browser Tooltips are controlled by the browser and not the grid.

Blank Values Copy Link

Tooltips are not shown for the missing values undefined, null and "" (empty String). To display tooltips for missing values, provide a tooltipValueGetter to return something that is not empty.

In the example below:

  • The data has missing values undefined, null and '' (empty String) as the first three rows.
  • Column A uses tooltipField, no tooltip is shown.
  • Column B uses tooltipValueGetter to return an object, tooltip is shown.

Row Groups Copy Link

When a column is grouped, the generated group column inherits the tooltip properties from the underlying column's Column Definition: tooltipField, tooltipValueGetter, tooltipComponent, and tooltipComponentParams. This is consistent with how valueFormatter is inherited. With groupDisplayType: 'multipleColumns', the group column header also inherits headerTooltip.

Cell tooltip properties set on autoGroupColumnDef (tooltipField, tooltipValueGetter, tooltipComponent) apply to leaf rows only. headerTooltip still applies to the group column header.

In the example below:

  • The Country and Year columns each define a tooltipValueGetter. Hover a group key to see the tooltip inherited from the underlying column.
  • autoGroupColumnDef defines a tooltipValueGetter. Hover a leaf row in the group column to see it.

autoGroupColumnDef cell tooltip properties apply to leaf rows only. Group rows inherit their cell tooltips from the underlying column colDef.

Grouped Column Headers Copy Link

With groupDisplayType: 'multipleColumns', each generated group column header inherits the headerTooltip from its underlying column colDef. Hover a group column header in the example below to see the inherited tooltip.

Full Width Group Rows Copy Link

With groupDisplayType: 'groupRows', full-width group rows inherit their tooltips from the underlying column colDef. Hover a group row in the example below to see the tooltip defined on the grouped column.

Mouse Tracking Copy Link

The example below enables mouse tracking to demonstrate a scenario where tooltips need to follow the cursor. To enable this feature, set the tooltipMouseTrack to true in the gridOptions.

Browser Tooltip Copy Link

Set the grid property enableBrowserTooltips=true to stop using rich HTML Components and use the browsers native tooltip.

Interactive Tooltips Copy Link

By default, it is impossible to click on tooltips and hovering them has no effect. If tooltipInteraction=true is set in the gridOptions, the tooltips will not disappear while being hovered and you will be able to click and select the text within the tooltip.

const tooltipInteraction = true;

<AgGridReact tooltipInteraction={tooltipInteraction} />

The example below enables Tooltip Interaction to demonstrate a scenario where tooltips will not disappear while hovered. Note following:

  • Tooltips will not disappear while being hovered.
  • Tooltips content can be selected and copied.

The example below shows Tooltip Interaction with Custom Tooltips. Note the following:

  • Tooltip is enabled for the Athlete and Age columns.
  • Tooltips will not disappear while being hovered.
  • The custom tooltip displays a text input and a Submit button which when clicked, updates the value of the Athlete Column cell in the hovered row and then closes itself by calling hideTooltipCallback().

Custom Component Copy Link

The grid does not use the browser's default tooltip, instead it has a rich HTML Tooltip Component. The default Tooltip Component can be replaced with a Custom Tooltip Component using colDef.tooltipComponent.

In the example below:

  • tooltipComponent is set on the Default Column Definition so it applies to all Columns.
  • tooltipComponentParams is set on the Athlete Column Definition to provide a Custom Property, in this instance setting the background color.

When a tooltip component is instantiated then the following will be made available on props:

Properties available on the CustomTooltipProps<TData = any, TValue = any, TContext = any> interface.

locationCopy Link
TooltipLocation
What part of the application is showing the tooltip, e.g. 'cell', 'header', 'menuItem' etc
The value to be rendered by the tooltip.
valueFormattedCopy Link
string | null
The formatted value to be rendered by the tooltip.
colDefCopy Link
ColDef | ColGroupDef | null
Column / ColumnGroup definition.
columnCopy Link
Column | ColumnGroup
Column / ColumnGroup
rowIndexCopy Link
number
The index of the row containing the cell rendering the tooltip.
The row node.
Data for the row node in question.
hideTooltipCallbackCopy Link
Function
A callback function that hides the tooltip
The grid api.
Application context as set on gridOptions.context.