In Salesforce Lightning web components, we use the lightning-helptext tag with the content attribute to display the Tooltip Text. The tooltip text is similar to the help text we define for the object fields while creating them.
In this Salesforce tutorial, we will learn about the Tooltip feature and how to display a tooltip in the Salesforce Lightning data table.
What is a Tooltip in Salesforce Lightning Web Components?
In Salesforce Lightning Web Components (LWC), a tooltip is a pop-up element that displays brief, relevant information about a UI element when a user hovers over or clicks on it. The element can be an object field, the header of a data table, or cells in the Lightning data table. To define the tooltip in the LWC component, we use the extension lightning-helptext in the HTML file.
This tooltip displays text that can be information about the record field or instructions for the user to fill in the details in the field. This is similar to the help text that we add to the object fields.
Display Tooltip on Salesforce Lightning Data Table
In the steps below, I will first create a sample LWC component to show the method of adding the tooltip. Then, we will display the tooltip in the Salesforce Lightning data table.
Add Tooltip in Salesforce Lightning Web Components
To add or display a tooltip in the Salesforce Lightning web components, create an LWC component and follow the steps below.
- Enter the code below in the HTML to display the tooltip in the LWC component.
<template>
<lightning-card>
<div class="slds-m-around_medium">
Salesforce LWC Tooltip <lightning-helptext content= "This is the tool tip Help Text">
</lightning-helptext>
<lightning-input variant="label-hidden"></lightning-input>
</div>
</lightning-card>
</template>
To add the tooltip in the LWC component, we have used the extension <lightning-helptext>, and within this, using content, we have defined the text that will appear when hovering over the tooltip icon.
- We are displaying a sample text in the component with a tooltip, so the JS file code will remain as it is.
import { LightningElement } from 'lwc';
export default class ToolTipText extends LightningElement {}
- Enter the code below in the meta.xml file to make the component visible to the Lightning pages.
isExposed>true</isExposed>
<targets>
<target>lightning__RecordPage</target>
<target>lightning__AppPage</target>
<target>lightning__HomePage</target>
</targets>
- Deploy the LWC component to the lightning page, and after this, you will see an info icon in the LWC component, and when we hover on the icon, it will display the tooltip text that we have entered in the content.

This way, we can add a tooltip in Salesforce Lightning web components using the lightning-helptext component.
Add Tooltip in Salesforce LWC Lightning Data Table
When creating a lightning data ta