Skip to content
This repository was archived by the owner on Jun 8, 2026. It is now read-only.

Commit 5b8d6b0

Browse files
committed
docs(tooltip): update topic with new properties and behavior changes
1 parent 3acf232 commit 5b8d6b0

1 file changed

Lines changed: 147 additions & 11 deletions

File tree

en/components/tooltip.md

Lines changed: 147 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,83 @@ If everything went well, you should see the sample shown in the [Tooltip Demo](#
153153
What if we want to control the amount of time that should pass before showing and hiding the tooltip? For this purpose we can use the [`showDelay`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html#showDelay) and the [`hideDelay`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html#hideDelay) properties of the [`igxTooltipTarget`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html) directive. Both properties are of type **number** and take time in milliseconds.
154154

155155
> [!NOTE]
156-
> The built-in UI interaction behavior of the [`IgxTooltipTargetDirective`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html) and its respective API methods work by taking [`showDelay`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html#showDelay) and [`hideDelay`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html#hideDelay) property values into account. Showing and hiding the tooltip through the API of the [`IgxTooltipDirective`]({environment:angularApiUrl}/classes/igxtooltipdirective.html) does not take the [`showDelay`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html#showDelay) and [`hideDelay`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html#hideDelay) property values into account. If necessary, such logic would have to be implemented manually according to the application's specifics.
156+
> The built-in UI interaction behavior of the [`IgxTooltipTargetDirective`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html) works by taking [`showDelay`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html#showDelay) and [`hideDelay`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html#hideDelay) property values into account. Showing and hiding the tooltip through the API or the API of the [`IgxTooltipDirective`]({environment:angularApiUrl}/classes/igxtooltipdirective.html) does NOT take the [`showDelay`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html#showDelay) and [`hideDelay`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html#hideDelay) property values into account. If necessary, such logic would have to be implemented manually according to the application's specifics.
157+
158+
### Overlay configuration
159+
160+
Both the [`igxTooltip`]({environment:angularApiUrl}/classes/igxtooltipdirective.html) and [`igxTooltipTarget`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html) directives use the [`IgxOverlayService`](overlay.md) to open and close the respective tooltip element.
161+
162+
The [`igxTooltipTarget`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html) directive exposes a [`positionSettings`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html#positionSettings) property, which can be used to customize the animations of our tooltip, its position in the UI and a lot more! If this property is not set, then default position settings will be used.
163+
164+
To further customize the tooltip, use the [`overlaySettings`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html#overlaysettings) property (inherited from the [`igxToggleAction`]({environment:angularApiUrl}/classes/igxtoggleactiondirective.html)).
165+
166+
```html
167+
<igx-icon [igxTooltipTarget]="tooltipRef" [positionSettings]="positionSettings" [overlaySettings]="overlaySettings">
168+
info
169+
</igx-icon>
170+
171+
<div #tooltipRef="tooltip" igxTooltip>Her name is Madelyn James</div>
172+
```
173+
```ts
174+
public positionSettings: PositionSettings = {
175+
horizontalDirection: HorizontalAlignment.Left,
176+
horizontalStartPoint: HorizontalAlignment.Left,
177+
verticalDirection: VerticalAlignment.Top,
178+
verticalStartPoint: VerticalAlignment.Bottom,
179+
openAnimation: useAnimation(slideInTop, { params: { duration: '2000ms' } }),
180+
closeAnimation: useAnimation(slideOutBottom, { params: { duration: '2000ms'} }),
181+
offset: 10
182+
}
183+
184+
public overlaySettings: OverlaySettings = {
185+
closeOnEscape: false,
186+
};
187+
```
188+
189+
> [!NOTE]
190+
> Any property that is set through the [`overlaySettings`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html#overlaysettings) will override the same property from the default overlay settings and will have a direct impact on the tooltip.
191+
192+
### Additional Properties
193+
194+
Apart from the properties we've already covered, the [`igxTooltipTarget`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html) offers a variety of additional properties that allow you to further configure the tooltip's behavior and appearance.
195+
196+
You can make the tooltip "sticky" using the [`sticky`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html#sticky) property, which adds a close button and keeps the tooltip visible until the user closes it manually - either by clicking the close button or pressing the `Esc` key. This behavior overrides the default hover behavior, preventing the tooltip from disappearing when the user stops hovering over the target element.
197+
198+
```html
199+
<igx-icon [igxTooltipTarget]="tooltipRef" [sticky]="true">
200+
info
201+
</igx-icon>
202+
203+
<div #tooltipRef="tooltip" igxTooltip>Her name is Madelyn James</div>
204+
```
205+
206+
To customize the default close button, use the [`closeButtonTemplate`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html#closebuttontemplate) property.
207+
208+
```html
209+
210+
<igx-icon [igxTooltipTarget]="tooltipRef" [sticky]="true" [closeButtonTemplate]="customTemplate">
211+
info
212+
</igx-icon>
213+
214+
<ng-template #customTemplate>
215+
<igx-icon>cancel</igx-icon>
216+
</ng-template>
217+
218+
<div #tooltipRef="tooltip" igxTooltip>Her name is Madelyn James</div>
219+
```
220+
221+
> [!NOTE]
222+
> Any custom content added via the `closeButtonTemplate` is rendered only when the tooltip is in sticky mode.
223+
224+
Additionally, you can add an arrow indicator to the tooltip by using the [`hasArrow`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html#hasarrow) property.
225+
226+
```html
227+
<igx-icon [igxTooltipTarget]="tooltipRef" [hasArrow]="true">
228+
info
229+
</igx-icon>
230+
231+
<div #tooltipRef="tooltip" igxTooltip>Her name is Madelyn James</div>
232+
```
157233

158234
## Rich tooltip
159235

@@ -272,15 +348,6 @@ If all went well, this is how our location and tooltip should look like:
272348

273349
<div class="divider--half"></div>
274350

275-
## Overlay configuration
276-
277-
Both the [`igxTooltip`]({environment:angularApiUrl}/classes/igxtooltipdirective.html) and [`igxTooltipTarget`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html) directives use the [`IgxOverlayService`](overlay.md) to open and close the respective tooltip element.
278-
279-
The [`igxTooltipTarget`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html) directive exposes an [`overlaySettings`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html#overlaysettings) property (inherited from the [`igxToggleAction`]({environment:angularApiUrl}/classes/igxtoggleactiondirective.html)), which can be used to customize the animations of our tooltip, its position in the UI and a lot more! If this property is not set, then default overlay settings will be used.
280-
281-
> [!NOTE]
282-
> Any property that is set through the [`overlaySettings`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html#overlaysettings) will override the same property from the default overlay settings and will have a direct impact on the tooltip.
283-
284351
## Styling
285352

286353
To get started with styling the tooltip, we need to import the `index` file, where all the theme functions and component mixins live:
@@ -340,14 +407,83 @@ So now our styled tooltip should look like this:
340407

341408
## Accessibility
342409

343-
Elements with the [`igxTooltip`]({environment:angularApiUrl}/classes/igxtooltipdirective.html) directive have an autogenerated [`id`]({environment:angularApiUrl}/classes/igxtooltipdirective.html#id) property (if not set by the developer), a tooltip [`role`]({environment:angularApiUrl}/classes/igxtooltipdirective.html#role) and the **aria-hidden** attribute that is automatically updated depending on whether the tooltip is visible or not. By setting the **aria-describedby** attribute of the target to its respective tooltip's [`id`]({environment:angularApiUrl}/classes/igxtooltipdirective.html#id), a reference will be provided to the tooltip element. This provides screen readers the information needed to read out the tooltip's contents when the end-user triggers the tooltip.
410+
The [`igxTooltip`]({environment:angularApiUrl}/classes/igxtooltipdirective.html) is built with accessibility in mind and includes the following properties and ARIA attributes:
411+
412+
- [`id`]({environment:angularApiUrl}/classes/igxtooltipdirective.html#id) property - autogenerated if not set by the developer.
413+
- [`role`]({environment:angularApiUrl}/classes/igxtooltipdirective.html#role) - When the tooltip is in its default behavior, `role="tooltip"` is applied. If the [`sticky`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html#sticky) property is enabled, the role changes to `status`.
414+
- `aria-hidden` - automatically updated depending on whether the tooltip is visible or not.
415+
416+
By setting the **aria-describedby** attribute of the target to its respective tooltip's [`id`]({environment:angularApiUrl}/classes/igxtooltipdirective.html#id), a reference will be provided to the tooltip element. This provides screen readers the information needed to read out the tooltip's contents when the end-user triggers the tooltip.
344417

345418
Extra care should be taken in the following scenarios:
346419

347420
- The tooltip's content is too complex to be automatically interpreted.
348421
- The tooltip is used with a manually implemented behavior (e.g. manually show/hide) instead of the built-in one.
349422
- The target element is unfocusable.
350423

424+
## Notes and Limitations
425+
426+
The [`igxTooltipTarget`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html) directive uses the `TooltipPositionStrategy` to position the tooltip and arrow element. If a custom [`positionStrategy`]({environment:angularApiUrl}/interfaces/overlaysettings.html#positioningStrategy) is used and [`hasArrow`]({environment:angularApiUrl}/classes/igxtooltiptargetdirective.html#hasarrow) is set to `true`, the custom strategy should extend the `TooltipPositionStrategy`. Otherwise, the arrow will not be displayed.
427+
428+
The arrow element is positioned based on the provided position settings. If the directions and starting points do not correspond to any of the [predefined position values](#predefined-position-values), the arrow is positioned in the top middle side of the tooltip (default tooltip position `bottom`).
429+
430+
#### Predefined position values
431+
432+
| Position     | Horizontal Direction          | Horizontal Start Point         | Vertical Direction            | Vertical Start Point           |
433+
|--------------|-------------------------------|--------------------------------|-------------------------------|--------------------------------|
434+
| top          | HorizontalAlignment.Center    | HorizontalAlignment.Center     | VerticalAlignment.Top         | VerticalAlignment.Top          |
435+
| top-start    | HorizontalAlignment.Right     | HorizontalAlignment.Left       | VerticalAlignment.Top         | VerticalAlignment.Top          |
436+
| top-end      | HorizontalAlignment.Left      | HorizontalAlignment.Right      | VerticalAlignment.Top         | VerticalAlignment.Top          |
437+
| bottom       | HorizontalAlignment.Center    | HorizontalAlignment.Center     | VerticalAlignment.Bottom      | VerticalAlignment.Bottom       |
438+
| bottom-start | HorizontalAlignment.Right     | HorizontalAlignment.Left       | VerticalAlignment.Bottom      | VerticalAlignment.Bottom       |
439+
| bottom-end   | HorizontalAlignment.Left      | HorizontalAlignment.Right      | VerticalAlignment.Bottom      | VerticalAlignment.Bottom       |
440+
| right        | HorizontalAlignment.Right     | HorizontalAlignment.Right      | VerticalAlignment.Middle      | VerticalAlignment.Middle       |
441+
| right-start  | HorizontalAlignment.Right     | HorizontalAlignment.Right      | VerticalAlignment.Bottom      | VerticalAlignment.Top          |
442+
| right-end    | HorizontalAlignment.Right     | HorizontalAlignment.Right      | VerticalAlignment.Top         | VerticalAlignment.Bottom       |
443+
| left         | HorizontalAlignment.Left      | HorizontalAlignment.Left       | VerticalAlignment.Middle      | VerticalAlignment.Middle       |
444+
| left-start   | HorizontalAlignment.Left      | HorizontalAlignment.Left       | VerticalAlignment.Bottom      | VerticalAlignment.Top          |
445+
| left-end     | HorizontalAlignment.Left      | HorizontalAlignment.Left       | VerticalAlignment.Top         | VerticalAlignment.Bottom       |
446+
447+
448+
#### Customizing the arrow's position
449+
450+
To customize the arrow's position, you can override the `positionArrow(arrow: HTMLElement, arrowFit: ArrowFit)` method.
451+
452+
For example:
453+
454+
```ts
455+
export class CustomStrategy extends TooltipPositioningStrategy {
456+
constructor(settings?: PositionSettings) {
457+
super(settings);
458+
}
459+
460+
public override positionArrow(arrow: HTMLElement, arrowFit: ArrowFit): void {
461+
Object.assign(arrow.style, {
462+
left: '-0.25rem',
463+
transform: 'rotate(-45deg)',
464+
[arrowFit.direction]: '-0.25rem',
465+
});
466+
}
467+
}
468+
469+
public overlaySettings: OverlaySettings = {
470+
positionStrategy: new CustomStrategy({
471+
horizontalDirection: HorizontalAlignment.Right,
472+
horizontalStartPoint: HorizontalAlignment.Right,
473+
verticalDirection: VerticalAlignment.Bottom,
474+
verticalStartPoint: VerticalAlignment.Bottom,
475+
})
476+
};
477+
```
478+
479+
```html
480+
<igx-icon [igxTooltipTarget]="tooltipRef" [hasArrow]="true" [overlaySettings]="overlaySettings">
481+
info
482+
</igx-icon>
483+
484+
<div #tooltipRef="tooltip" igxTooltip>Her name is Madelyn James</div>
485+
```
486+
351487
## API References
352488

353489
In this article we learned how to create, configure and style awesome tooltips for the elements on our page! We also used some additional Ignite UI for Angular components like icons and avatars to improve on the design of our application! The respective APIs are listed below:

0 commit comments

Comments
 (0)